mysql in 方法查询 按照 in队列里的顺序排序

String sql = "select comm,avg(price) from comm_saleprice where zone = ? and comm in (?,?,?,?,?,?,?,?) and price <> '0' GROUP BY comm "
                    + "order by field(comm,?,?,?,?,?,?,?,?)";
            stmt = conn.prepareStatement(sql);
            stmt.setString(1, zone);
            stmt.setString(2, top1);
            stmt.setString(3, top2);
            stmt.setString(4, top3);
            stmt.setString(5, top4);
            stmt.setString(6, top5);
            stmt.setString(7, top6);
            stmt.setString(8, top7);
            stmt.setString(9, top8);
            stmt.setString(10, top1);
            stmt.setString(11, top2);
            stmt.setString(12, top3);
            stmt.setString(13, top4);
            stmt.setString(14, top5);
            stmt.setString(15, top6);
            stmt.setString(16, top7);
            stmt.setString(17, top8);

 

posted on 2016-12-29 10:35  山高似水深  阅读(330)  评论(0编辑  收藏  举报

购买方式 点击下面图标购买