我需要选择存在于users表中但不存在于表groups_members、groups_members_unapproved和groups_invitations中的记录。
$_POST['msg_id']包含多个用户 ID,我不知道如何在 3 个子查询中使用implode语句,所以我将其替换为 ??? - 问号。
谢谢。
$result = mysql_query("SELECT id FROM users
WHERE id IN (". implode(', ', $_POST['msg_id']).")
AND id NOT IN (SELECT memberid FROM groups_members where memberid='???' and groupid='$cid')
AND id NOT IN (SELECT memberid FROM groups_members_unapproved where memberid='???' and groupid='$cid')
AND id NOT IN (SELECT invited FROM groups_invitations where invited = '???' and groupid='$cid')",$gb1) or die('Error');