left join不同写法导致数据差异

select m.*, p.specification, p.sales_price, p.promotion_price
from product_detail p
left join PRODUCT_IMAGE m on m.head_id = p.id and image_type = 1
and m.image_type = 1
and m.platform = 1
and m.type = 2
and m.orderby = 1
where p.serial_id = '42F4BE87AA0D43D98AAB99AE7B2A0DA0'

这种写法能正确的以product_detail的serial_id为条件得到记录数2


select m.*, p.specification, p.sales_price, p.promotion_price
from product_detail p
left join PRODUCT_IMAGE m on m.head_id = p.id
where p.serial_id = '42F4BE87AA0D43D98AAB99AE7B2A0DA0'
and m.image_type = 1
and m.platform = 1
and m.type = 2
and m.orderby = 1

相当于inner join

posted @ 2016-09-21 13:31  Season2009  阅读(462)  评论(0编辑  收藏  举报