我使用下面的查詢的條目不存在返回值:即使
SELECT shop_entrys.id, shop_images.path FROM shop_entrys,shop_images
WHERE shop_entrys.id = shop_images.s_id AND
shop_images.pos = 0 AND
shop_entrys.category_id = 1
ORDER BY shop_entrys.pos ASC
然而,在shop_entrys行可能與shop_images沒有聯繫到行存在。因此,... WHERE shop_entrys.id = shop_images.s_id ...將不會被滿足。在這種情況下,我仍然想返回結果。例如:
shop_entrys.id shop_images.path 1 "/img1.jpg" ... ... 42 "not found"
我應該如何改變上述查詢仍返回一個結果?
使用左外連接 – Kickstart
['COALESCE'](http://dev.mysql.com/doc/ refman/5.7/EN /比較-operators.html)? –