select *... where id IN(12,11,10,4)我想要成这样,但出现的是select *... where id IN(‘12,11,10,4’)出现的结果只人一条ID=12的
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
select instr((select picture from upfiles where id=77),'12') 测试一下,准确的要两头加逗号
select * from upfiles where id in( SELECT picture FROM msg where id=77 ) 我想要的结果是:4条记录 12 及其内容 11 及其内容 10 及其内容 4 及其内容
没有记录无法测试, select instr((select picture from upfiles where id=77),'12') 测试没有
我觉得,in 是在同一行的字符之间的。 SELECT picture FROM msg where id=77 结果为:'12,11,10,4' 是一个结果集,其实是4行,因此每次只能取得第一行的值。 不知道是不是这个原因
select *... where id IN(12,11,10,4)?
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
测试一下,准确的要两头加逗号
我想要的结果是:4条记录
12 及其内容
11 及其内容
10 及其内容
4 及其内容
select instr((select picture from upfiles where id=77),'12')
测试没有
SELECT picture FROM msg where id=77 结果为:'12,11,10,4' 是一个结果集,其实是4行,因此每次只能取得第一行的值。
不知道是不是这个原因
1 处理字符串 分别把12 11 10 4 赋值给不同的整形数
2 使用预处理重新生成 select ...in... 这个句子
select instr((select picture from upfiles where id=77),id) from tt
where instr((select id1 from tth where id=1),id)>0
测试通过
试试这句
select *... where id IN ('12,11,10,4') group by id
如:
todept=12,11,10,4';
select * from table1 where instr(concat(",",todept,","),concat(",",id,","))>0;
这种方式可以解决这问题。