1.in 后面是记录集,如:
select * from table where uname in(select uname from user)2.in 后面是字符串,如:
select * from table where uname in('aaa',bbb','ccc','ddd','eee',ffff'')注意:这里一定要将字符串用单引号'' 标注起来;
3.in 后面是数组,用如下方法,请参考:
//$pieces是含数据的数组for($i=0$i<count($pieces)$i++){
$uname=$uname."'".$pieces[$i]."',"
}
$the_uname ="uname in(".$uname."'')"
select * from table where ".$the_uname."
备注:这种方法的原理其实很简单,二就是把数组编程上面“第2种情况”的形式。
Select * From UserWhere exists (Select * From UserTag Where User.Uid = UserTag.Uid and TagCode =3)
and exists (Select * From UserTag Where User.Uid = UserTag.Uid and TagCode=4)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)