【发布时间】:2012-08-15 22:22:26
【问题描述】:
我有三个表,product、category 和 product_to_category。产品有主键product_id、类别category_id和product_to_category p2c_id。 Product_to_ category 使用产品各自的 ID 以多对多关系将产品链接到类别。
基本上,我想编写一个查询,从类别表中不存在的类别中选择所有产品。这是因为产品是从另一个数据库迁移过来的。
我有这样的东西,但有点失落。
SELECT *
FROM product AS p
LEFT JOIN product_to_category AS p2c ON p.product_id = p2c.product_id
LEFT JOIN category AS c ON c.category_id
基本上就我所知。我需要将类别表加入到 product_to_category category_id 不在类别表中的 product_to_category 表中。我可能完全走错了路,但被卡住了! 提前致谢。
【问题讨论】: