SELECT
p.name AS pname,
p.icon AS icon,
p.price AS price,
p.original_price AS original_price,
p.prod_id AS prod_id,
p.stock AS stock,
p.views AS views,
s.name AS sname
FROM `product` as p
JOIN
`store` as s ON p.store_id = s.store_id
WHERE
p.active = '1'
ORDER BY `prod_id` DESC
當 s.store_id 移除之後
這一段查詢就完全錯誤了
有什麼改寫方式
可以即便 s.store_id 移除,仍然可以顯示數據?
補充
每個 product 都有一個 store_id
但是當其中一個product的store_id被移除,這段就無法查詢...
恩...你要的是這樣?
SELECT
p.name AS pname,
p.icon AS icon,
p.price AS price,
p.original_price AS original_price,
p.prod_id AS prod_id,
p.stock AS stock,
p.views AS views,
'' AS sname
FROM `product` as p
WHERE
p.active = '1'
ORDER BY `prod_id` DESC