首页 > 其他 > 详细

left join 注意

时间:2016-09-21 14:24:36      阅读:224      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!