我创建了以下查询,选择了我需要的数据
SELECT par.wo, l.addr, eml.maildate, lp.workdate
FROM parsed AS par, emails AS eml, list AS l, locateparsed AS lp
WHERE par.status != 0 AND eml.id = par.origid AND par.wo = l.wo AND par.wo = lp.wo
是否可以让每个返回的行检查一个匹配的'wo'的“已完成”表,如果使用一个查询匹配则不输出它?
答案 0 :(得分:1)
这正是为什么逗号分隔的表格让我非常恼火,你只是看不到连接类型使用的明显问题。试试这个:
SELECT
par.wo,
l.addr,
eml.maildate,
lp.workdate
FROM
parsed AS par
INNER JOIN emails AS eml ON eml.id = par.origid
INNER JOIN list AS l ON par.wo = l.wo
INNER JOIN locateparsed AS lp ON par.wo = lp.wo
LEFT JOIN completed ON par.wo = completed.wo
WHERE
par.status != 0
AND completed.wo IS NULL