mysql select in

来源:互联网 发布:淘宝店铺装修图片 编辑:程序博客网 时间:2024/06/17 03:25

select in在mssql和mysql下的差别:


mssql:

select * from upfiles where id in( SELECT picture FROM msg where id=77 );
SELECT picture FROM msg where id=77 结果为:'12,11,10,4'
select * from upfiles where id in( SELECT picture FROM msg where id=77 )结果为:12,11,10,4


mysql:

select * from upfiles where id in( SELECT picture FROM msg where id=77 );
SELECT picture FROM msg where id=77 结果为:'12,11,10,4'
select * from upfiles where id in( SELECT picture FROM msg where id=77 )结果为:12


mssql修正写法:

select * from upfiles where instr(( SELECT picture FROM msg where id=77 ),id)>0;

结果为:12,11,10,4

原创粉丝点击