码迷,mamicode.com
首页 > 其他好文 > 详细

left join 注意

时间:2016-09-21 14:25:21      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:

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

left join 注意

标签:

原文地址:http://www.cnblogs.com/season2009/p/5892303.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!