不知道该怎么做。
我有两个表格结果和受访者
我需要查看响应者表中是否有任何行具有completion ='Complete'但是他们的respondent_id(在结果表和响应者表中都是)不在结果表中?
有什么想法吗?
答案 0 :(得分:1)
SELECT respondent.* FROM respondent LEFT JOIN results
ON respondent.id = results.id
WHERE results.id IS NULL;
AND respondents.completion = 'Complete'
答案 1 :(得分:0)
或许类似于此。
SELECT r1.* FROM respondents r1
LEFT JOIN results r2 ON r1.respondent_id = r2.respondent_id
WHERE r1.completition = 'Complete' AND r2.respondent_id IS NULL;