我从表LABELS
中选择所有记录,我和INNER JOIN
也使用SELECT
来获取其他表中存在的其他一些数据。所以我的问题是:
SELECT LABELS.oldLabel, LABELS.label, LABELS.version, LABELS.description, LABELS.type, LABELS.cutter, LABELS.valid, LABELS.dateCreated, LABELS.dateModified, CUSTOMERS.name AS customer, CUSTOMERS.id, SUPPLIERS.name AS supplier FROM LABELS
INNER JOIN CUSTOMERS
ON LABELS.customer = CUSTOMERS.id
INNER JOIN SUPPLIERS
ON LABELS.supplier = SUPPLIERS.id
GROUP BY LABELS.oldLabel, LABELS.label, LABELS.version, LABELS.description, LABELS.type, LABELS.cutter, LABELS.customer, LABELS.valid, CUSTOMERS.name , CUSTOMERS.id, SUPPLIERS.name
表格LABELS
中的记录大小为3169
。但是,上面的语句返回3089
。 80
个记录丢失了。
有没有办法获取所有记录,除了上面的选择,以便查看这些记录是什么,并弄清楚为什么没有选择它们?
我试过了:
Select * FROM labels where not exists( the_above_select)
但我没有得到任何记录......
答案 0 :(得分:1)
SELECT * from Labels WHERE label NOT IN
(SELECT label from Labels INNER JOIN CUSTOMERS
ON LABELS.customer = CUSTOMERS.id
INNER JOIN SUPPLIERS
ON LABELS.supplier = SUPPLIERS.id)