Code statement of multiple left joins combined with dynamic 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>
Please bring the original link to reprint ,thank
Similar articles

2021-10-14

2021-10-14

2021-10-14

2021-10-14

2021-10-14

2021-10-14

2021-10-14

2021-10-14

2021-10-14

2021-10-14

2021-10-14

2021-10-14

2021-10-14