使用 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