我需要从一个表(t1)中选择项目,但排除在另一个表(t2)中具有id并且具有相同项目ID的任何结果。
SELECT *
FROM t1
WHERE project = 10
需要排除t2中存在的任何行。
t1.userID = t2.memberID AND t2.projectID = t1.project
不确定如何把它们放在一起......
答案 0 :(得分:4)
SELECT t1.*
FROM t1
LEFT OUTER JOIN t2 ON t1.userID = t2.memberID AND t2.projectID = t1.project
WHERE t1.project = 10 and t2.projectID IS NULL