我有两列,一列是member_id,另一列是connection_member_id。我必须检查是否已在数据库中插入member和connection_member,然后不要将其插入。

试图获取这样的东西

SELECT * FROM `mlm_connections` mc
LEFT JOIN temp_connections_members tcm
ON tcm.member_id != mc.member_id
AND tcm.connection_member_id != mc.connection_member_id;

最佳答案

尝试这个

SELECT * FROM `mlm_connections` mc
WHERE mc.member_id  NOT Exists (SELECT member_id  FROM temp_connections_members) AND
      mc.connection_member_id NOT Exists (SELECT connection_member_id  FROM temp_connections_members)

关于mysql - MySQL查询问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23868218/

10-11 22:23