select * from zan where uid not in(select uid from zan where zhongjiang !=0) group by uid order by rand() limit 40
不过这个执行效率比较低,正在找更好用的方法
我觉得还是不如两条语句分开来写,先查出所有的uid,然后再用not in 这样查询速度快很多
$sql="select uid from zan where zhongjiang !='0'";
$res=$dbs->query($sql);
$uid='';
while($o=$dbs->fetch_object($res)){
$uid.=$o->uid.',';
}
$uid=substr($uid,0,strlen($uid)-1);
$sql="select * from zan where uid not in($uid) group by uid order by rand() limit 40";
$res=$dbs->query($sql);
$arr=array();
while($o=$dbs->fetch_object($res)){
$arr[]=$o;
}
http://www.ink520.com/
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步