mybaties模糊查询按时间查询

<select id="listUserFavorites" parameterMap="favoritesParam"  resultType="hashmap">
	     select 
			fa.favorites_id as favoritesId,
			fa.target_id as targetId,
			fa.target_sku as targetSku,
			fa.target_url as targetUrl,
			fa.favorites_time as favoritesTime,
			g.goods_img as goodsImg,
            g.tags as tags,
            g.goods_name as goodsName,
			sku.sku_name as skuName,
            sku.shop_price as goodsPrice 
	    from  US_favorites fa,gd_goods g,gd_goods_sku sku
		where fa.target_id=g.goods_id and fa.target_sku=sku.sku_id and fa.user_id=#{userId, jdbcType=INTEGER}
	   <where>
			<trim prefixOverrides="and">
				<if test="goodsName != null">and g.goods_name like concat('%',#{goodsName},'%')</if>
				<if test="seachTime!=null and seachTime!=''">
   				  <![CDATA[   and DATE_FORMAT(fa.favorites_time, '%Y-%m-%d')<=DATE_FORMAT(#{seachTime!}, '%Y-%m-%d')   ]]>
				</if>
			</trim>
		</where>
	    order by fa.favorites_time desc
        <if test="size != -1">
		   limit #{start},#{size}
		</if>       
	</select>

猜你喜欢

转载自blog.csdn.net/semial/article/details/80737948