当我选择像这样的表时:select count(*) from products
返回12900结果。
我有一个关系查询,它返回多个表关系结果,如下所示:
SELECT category.name,
manifacturer.name,
supplier.name,
product.name
FROM products as product,
suppliers as supplier,
manifacturers as manifacturer,
categories as category
WHERE product.sid=supplier.id AND
product.manid = manifacturer.id AND
product.catid = category.id
该查询返回12873个结果,
所以我找不到哪个数据不匹配。如何找到丢失的数据?我使用了NOT查询,但未返回任何结果。
您可以看到带有FULL OUTER JOIN的不匹配记录,如下所示:
SELECT prod.id, rel.id FROM (
SELECT category.name,
manifacturer.name,
supplier.name,
product.name
FROM products as product,
suppliers as supplier,
manifacturers as manifacturer,
categories as category
WHERE product.sid=supplier.id AND
product.manid = manifacturer.id AND
product.catid = category.id
) as rel
FULL OUTER JOIN products as prod
ON rel.id = prod.id
因此,您可以在列表中看到空ID,而不是空ID。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句