I cannot change my code to left join is null while I am trying use where in table2. Please see my query bellow
当我尝试在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
Can you please explain even it's not useful or bad question. It is my real problem.
你能解释一下,即使这不是有用或不好的问题。这是我真正的问题。
1 个解决方案
#1
1
Why can't you use left join?
为什么你不能使用左连接?
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
Also, your assumption that left join is better is not necesarrily correct. The article linked by TsSkTo in the comments to your question shows that left join is a worse solution for MSSQL
此外,您认为左连接更好的假设并不是必须正确的。 TsSkTo在你的问题评论中链接的文章表明,左连接对于MSSQL来说是一个更糟糕的解决方案
#1
1
Why can't you use left join?
为什么你不能使用左连接?
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
Also, your assumption that left join is better is not necesarrily correct. The article linked by TsSkTo in the comments to your question shows that left join is a worse solution for MSSQL
此外,您认为左连接更好的假设并不是必须正确的。 TsSkTo在你的问题评论中链接的文章表明,左连接对于MSSQL来说是一个更糟糕的解决方案