多个left join结合动态sql的代码语句
Posted 来老铁干了这碗代码
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了多个left join结合动态sql的代码语句相关的知识,希望对你有一定的参考价值。
<sql id="unionColumns">
b.id AS id
, b.gmt_create AS gmtCreate
, b.gmt_modified AS gmtModified
, b.corp_id AS corpId
, b.corp_name AS corpName
</sql>
<sql id="baseColumns">
b.id,
b.gmt_create,
b.gmt_modified,
b.corp_id,
b.corp_name,
e.assign_time,
</sql>
<sql id="Where_CorpDeploy">
<if test="corpId != null">
and b.corp_id = #{corpId}
</if>
<if test="corpName != null">
and b.corp_name LIKE concat('%',#{corpName},'%')
</if>
</sql>
<sql id="limitSql">
limit
<if test="pageNo > 0">
#{start},
</if>
<if test="pageNo=0">0,</if>
#{pageSize}
</sql>
<select id="xxxDeployDO" resultType="xxx.DeployDO"
parameterType="xxx.Query">
SELECT
<include refid="unionColumns"/>
FROM (
SELECT
<include refid="baseColumns"/>
FROM corp_deploy_info b
left join corp_deploy_assign e
on e.id = b.deploy_assign_id
left join corp_gmv c
on b.corp_id = c.corp_id
WHERE 1 = 1
<include refid="Where_CorpDeploy"/>
<include refid="limitSql"/>
)b
left join corp_gmv c
on b.corp_id = c.corp_id
</select>
以上是关于多个left join结合动态sql的代码语句的主要内容,如果未能解决你的问题,请参考以下文章
关于VF中select left(right) join的准确用法