mybatis 查询

mybatis 查询

查询一段时间内增加的公司:<=  在 xml 中要写成:  &gt;= 

    <select id="findCompanyInfoPage" resultMap="baseMap" parameterType="java.lang.String">
        SELECT
        a.company_name,a.company_address,b.user_telephone,a.create_time,b.user_nick_name
        FROM trade_company_info a,se_user b,app_crm_rel c
        WHERE b.sid=c.app_user_id AND c.company_id=a.sid AND b.user_role IN
        ('2','3')
        <if test=" startDate != null and startDate != '' ">
            AND DATE_FORMAT(a.create_time,'%Y-%m-%d') &gt;= #{startDate}
        </if>
        <if test=" endTime != null and endTime != '' ">
        AND DATE_FORMAT(a.create_time,'%Y-%m-%d') &lt;= #{endTime}
        </if>
        limit #{start},#{pageSize}
    </select>

 

 

 mapper.java 中的方法:

List<Map<String,Object>> findCompanyInfoPage(@Param("startDate")String startDate,@Param("start")int start,@Param("pageSize")int pageSize,@Param("endTime")String endTime);

 

 

mybatis xml 中的 等于是 == , sql 是 = 

 <if test="reqParam.state  != null and reqParam.state != '' and reqParam.state == 'REJECTANDNORMAL' ">
            AND ( a.state = 'REJECT' or a.state = 'NORMAL' )
        </if>
        <if test="reqParam.state  != null and reqParam.state != '' and reqParam.state != 'REJECTANDNORMAL' ">
            AND a.state = #{reqParam.state}
        </if>

 

posted @ 2018-09-20 10:47  zhoudingzhao  阅读(162)  评论(0编辑  收藏  举报