1. <select id="getOrdersGoodByTime" resultMap="BaseResultMap">
select
distinct resourceId,goods_name(去掉俩个字段都重复的情况)
from orders_goods
<where>
<choose> (if,else这样的逻辑)
<when test="resourseId != null">
and resourceId=#{resourseId}
</when>
<otherwise>
and resourceId!="null"
</otherwise>
</choose>
(between and 的使用)
<if test="begin!=null and end!=null">
and create_time between #{begin} and #{end}
</if>
</where>
</select>
2.<select id="getGoodsListByTime" resultType="java.util.Map">
SELECT
distinct goods_category_sort.*
from goods,goods_category_sort
WHERE
goods.goods_id=goods_category_sort.goods_id and
<if test="list!=null">
<foreach collection="list" index="index" item="categoryId" open="goods_category_sort.category_id IN(" separator="," close=")">
#{categoryId}
</foreach>
</if>
<if test="list!=null">
<if test="list.size()>0">
and
</if>
</if>
goods.status=2
ORDER by goods_category_sort.sort_id asc,goods_category_sort.goods_id asc
</select>
3.
SELECT
*
FROM
orders os where DATE_SUB( CURDATE( ), INTERVAL 3 DAY ) <= date( os.create_time )
4.聚合函数后面要加分组