<!--根据条件商品列表-->
<select id="getGoodsPage" resultType="com.enation.app.javashop.model.goods.dos.GoodsDO" useCache="false">
select goods.*
from es_goods goods
right join es_promo_goods promo on promo.goods_id = goods.goods_id
<where>
<if test="categoryIds!=null">
goods.category_id in
<foreach collection="categoryIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="keyWord!=null and keyWord != ''">
and
goods.goods_name LIKE concat('%',#{keyWord},'%')
</if>
</where>
</select>
第一次完整的写双表联查,其实这里的品类筛选应该可以写成三表联查的,待后期优化补充(8.15)
待解决的问题:
1.多表联查效率高还是使用代码(例如遍历循环匹配)进行处理筛选的效率高?
2.left join 、right join、inner join三者的区别