Jika tabel product
mengandung setidaknya satu data. Dan Anda ingin menampilkan kolom lain baik NULL
atau string khusus seperti "---"
Anda harus menentukan dalam kueri yang bergabung meskipun atribut bergabung adalah nol. Jadi kueri berikut akan memberi Anda data.
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);