当我尝试在 table2 中使用 where 时,我无法将我的代码更改为 left join is null。请在下面查看我的查询
SELECT table1.column1, table1.column2
FROM table1
WHERE NOT
EXISTS (
SELECT table2.column1, table2.column2
FROM table2
WHERE table2.column1= table1.column1
AND table2.location_id= 6
)
GROUP BY Barcode
即使这个问题没用或不好,你能解释一下吗?这是我真正的问题。
最佳答案
为什么不能使用左连接?
SELECT table1.column1, table1.column2
FROM table1
LEFT JOIN table2
ON table2.column1= table1.column1
AND table2.location_id= 6
WHERE table2.column1 is null
GROUP By Barcode
此外,您认为左连接更好的假设不一定正确。 TsSkTo 在对您的问题的评论中链接的文章表明,左连接对于 MSSQL 来说是一个更糟糕的解决方案
关于mysql - 使用 left join is null 而不是 where not exists in mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18586730/