Prestashop数据库的相反SQL查询|显示不在仓库中的产品

2022-08-07 00:00:00 sql select mysql prestashop

我需要有关SQL查询的帮助。基本上,我正在寻找的产品不在仓库中,在Prestashop数据库(电子商务CMS,仅供参考)。我在表PS_PRODUCT_LANG中有这个产品列表,在这个表中我还可以看到产品的名称,我将产品的ID连接到这个表中,以便从处理仓库的另外两个表(PS_WARAINE_PRODUCT_LOCATION和PS_WARAGE)中恢复信息。我进行了查询,以显示产品在哪个仓库中,即这个仓库:

SELECT A.id_product AS IdProd, A.name AS Nome, B.id_warehouse AS IdMag, C.name AS Magazzino FROM ps_product_lang A
INNER JOIN ps_warehouse_product_location B ON A.id_product = B.id_product
INNER JOIN ps_warehouse C on B.id_warehouse = C.id_warehouse
WHERE 1

现在,当然,我需要的恰恰相反。请记住,产品ID位于PS_PRODUCT_LANG表中。我如何才能做到这一点?

提前感谢各位!


解决方案

SELECT A.id_product AS IdProd, A.name AS Nome, B.id_warehouse AS IdMag, C.name AS Magazzino FROM ps_product_lang A
LEFT JOIN ps_warehouse_product_location B ON A.id_product = B.id_product
LEFT JOIN ps_warehouse C on B.id_warehouse = C.id_warehouse
WHERE C.id_warehouse IS NULL

相关文章