我有以下类型的查询:
select * from tbl_1 where [cond] as aliasA LEFT JOIN tbl_2 as aliasB
ON (aliasA.id = aliasB.id) WHERE aliasB.id IS NULL
它似乎在工作,只是忽略了最后一个
WHERE aliasB.id IS NULL
。所以,它返回的结果是:
select * from tbl_1 where cond as aliasA LEFT JOIN tbl_2 as aliasB
ON (aliasA.id = aliasB.id)
如何更改上述查询以获取
查询tbl_1的结果,其中[cond]只显示不在tbl_2中的行?
提前谢谢!
最佳答案
你可以试试:
SELECT * FROM tbl_1 aliasA LEFT JOIN tbl_2 aliasB
ON aliasA.id = aliasB.id
WHERE condA
AND aliasB.id IS NULL