SELECT p.product_id, p.quantity, p.price, pd.name, pd.description
FROM product AS p
INNER JOIN product_description AS pd ON p.product_id = pd.product_id
WHERE p.product_id = 1 AND pd.landuage_id = 5
在此查询中,只存在一个条件,在这种情况下为p.product_id
,但另一个条件pd.landuage_id
不存在。我希望执行请求,无论它是否存在。怎么做?
答案 0 :(得分:1)
可能重复,但正确答案是:
SELECT p.product_id, p.quantity, p.price, pd.name, pd.description
FROM product p
LEFT JOIN product_description pd ON p.product_id = pd.product_id AND pd.language_id = 5
WHERE p.product_id = 1;