Als tabel product
bevat ten minste één gegevens. En u wilt andere kolommen weergeven, ofwel NULL
of aangepaste tekenreeks zoals "---"
je moet in de query specificeren dat join zelfs als join-attribuut null is. Dus de volgende zoekopdracht geeft u gegevens.
SELECT
p.description AS p_description ,ifnull(pd.description,"---") AS pd_description,
ifnull(psd.description,"--") AS psd_description
FROM product AS p
LEFT JOIN Product_description AS pd ON(pd.product_id = p.product_id)
LEFT JOIN product_store_description AS psd ON(psd.product_id = p.product_id)
WHERE p.product_id = '1' AND (pd.language = 'en' or pd.language is null)
AND (psd.language = 'en' or psd.language is null) AND
(psd.store_id = 1 or psd.store_id is null);