我有以下工作 MySQL 查询:
SELECT
a.id id,
a.price price,
a.stock stock,
a.max_per_user max_per_user,
a.purchased purchased,
b.quantity owned
FROM
shop_items a
JOIN shop_inventory b
ON b.iid=a.id
AND b.cid=a.cid
WHERE
a.cid=1
AND a.szbid=0
AND a.id IN(3,4)
JOIN
加入表shop_inventory b
返回b.quantity owned
。但是,如果shop_inventory b
表中没有b.iid=a.id
我希望它返回的记录b.quantity = 0
。我该怎么做?