xml文件连表查询

前端之家收集整理的这篇文章主要介绍了xml文件连表查询前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

 

 

<!-- 根据条件查询资产信息 -->
    <select id="getAssetCommonByPage" resultType="java.util.Map">
        SELECT 
        *,t2.name as category_name,t3.name as type_name
        FROM 
        s_it_asset_common t1
        LEFT JOIN 
        s_asset_category t2 
        ON 
        t1.category = t2.id 
        LEFT JOIN
        s_asset_type t3 
        ON 
        t1.type = t3.id
        WHERE 1=1
        <if test="id !=‘‘ and id != null">
            AND
            id=#{id,jdbcType=NUMERIC}
        </if>
        <if test="code !=‘‘ and code != null">
            AND
            code=#{code}
        </if>
        <if test="category !=‘‘ and category != null">
            AND
            category=#{category}
        </if>
        <if test="type !=‘‘ and type != null">
            AND
            type=#{type}
        </if>
        <if test="mfr !=‘‘ and mfr != null">
            AND
            mfr like CONCAT(%,#{mfr},%)
        </if>
        <if test="ip !=‘‘ and ip != null">
            AND
            ip=#{ip}
        </if>
        <if test="name !=‘‘ and name != null">
            AND
            name like CONCAT(%,#{name},%)
        </if>
        <if test="currPage != null and currPage != ‘‘ and pageSize != null and pageSize != ‘‘">
            limit ${currPage - 1},${pageSize}
        </if>
    </select>

猜你在找的XML相关文章