有两个表:
1、pm_ci
2、pm_stu
当我执行如下sql的时候,结果如图:
SQL语句:
select a.ci_id,instr(replace(a.stu_ids,',',''),b.stu_id)
from pm_ci a,pm_stu b
where a.ci_id=2
and instr(replace(a.stu_ids,',',''),b.stu_id)>0
结果为:
符合我预期的结果。
但是加了一句 条件之后,我迷惘了
SQL语句:
select a.ci_id,instr(replace(a.stu_ids,',',''),b.stu_id)
from pm_ci a,pm_stu b
where a.ci_id=2
and instr(replace(a.stu_ids,',',''),b.stu_id)>0
and instr(replace(a.stu_ids,',',''),b.stu_id)= b.stu_id
结果:
为何只返回1。。。。
2被谁吃了。。。