我們試圖從MySQL數據庫上的多個表中進行選擇。在MySQL中還包含NULL行SELECT Query
我們的查詢是:
SELECT r.reviews_id,
r.customers_name,
r.date_added,
rd.reviews_text,
r.reviews_rating,
c.customers_email_address
FROM reviews r, reviews_description rd, customers c
WHERE r.customers_id = c.customers_id
AND r.reviews_id = rd.reviews_id
AND r.products_id = '74'
AND r.approved='1'
ORDER BY LENGTH(rd.reviews_text) DESC
但是,表reviews
也對現場customers_id
命令WHERE r.customers_id = c.customers_id
是限制其只能有一個customers_id
我場NULL項想知道我們如何也可以選擇NULL字段?我們嘗試過WHERE (r.customers_id = c.customers_id) OR (r.customers_id IS NULL)
- 但這不起作用。
非常感謝您的幫助。
或條件應該是這樣的(r.customers_id = C .customers_id或r.customers_id IS NULL) – JYoThI