本文介紹了Prestashop數(shù)據(jù)庫的相反SQL查詢|顯示不在倉庫中的產(chǎn)品的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我需要有關(guān)SQL查詢的幫助。基本上,我正在尋找的產(chǎn)品不在倉庫中,在Prestashop數(shù)據(jù)庫(電子商務CMS,僅供參考)。我在表PS_PRODUCT_LANG中有這個產(chǎn)品列表,在這個表中我還可以看到產(chǎn)品的名稱,我將產(chǎn)品的ID連接到這個表中,以便從處理倉庫的另外兩個表(PS_WARAINE_PRODUCT_LOCATION和PS_WARAGE)中恢復信息。我進行了查詢,以顯示產(chǎn)品在哪個倉庫中,即這個倉庫:
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
現(xiàn)在,當然,我需要的恰恰相反。請記住,產(chǎn)品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
這篇關(guān)于Prestashop數(shù)據(jù)庫的相反SQL查詢|顯示不在倉庫中的產(chǎn)品的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,