//sql1
select * from 表A where typeId in (1,2,3);
//sql2
select * from 表A where typeId=1 OR typeId=2 OR typeId =3;
-----------------------------------
ID | typeId
-----------------------------------
1 1
-----------------------------------
1 2
-----------------------------------
2 3
-----------------------------------
很明显,sql1查询出来的就2条记录,但sql2有3条记录,可以通过DISTINCT来让sql2实现sql1的同样的效果,但麻烦些,所以有要看什么时候用IN,什么时候用=!
浙公网安备 33010602011771号