MySQL 查询in操作,查询结果按in集合顺序显示的实现代码,需要的朋友可以参考下. MySQL 查询in操作,查询结果按in集合顺序显示 复制代码代码如下: select * from test where id in(3,1,5) order by find_in_set(id,'3,1,5'); select * from test where id in(3,1,5) order by substring_index('3,1,2',id,1); 偶尔看到的...或许有人会注意过,但我…
数据准备: 创建表: create table students( id int unsigned primary key auto_increment not null, name varchar(20) default '', age tinyint unsigned default 0, height decimal(5,2), gender enum('男','女','人妖','保密'), cls_id int unsigned default 0, isdelete bit defau…
MySQL 查询in操作,查询结果按in集合顺序显示 select * from test where id in(3,1,5) order by find_in_set(id,'3,1,5'); select * from test where id in(3,1,5) order by substring_index('3,1,2',id,1); 偶尔看到的...或许有人会注意过,但我以前真不知道 SQL: select * from table where id IN (3,6,9,1…