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);
转载注明出处
如果本文对你有帮助,请帮忙啦~~
打开支付宝首页搜“522901509”领红包,领到大红包的小伙伴赶紧使用哦!