我使用下面的查询的条目不存在返回值:即使
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)? –