使用 NOT EXISTS
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
使用 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
本条目发布于[2014年5月5日](https://c4ys.com/archives/199 "09:38")。属于[Database](https://c4ys.com/archives/category/database)分类,被贴了 [sql](https://c4ys.com/archives/tag/sql) 标签。