// 对某一列做多行转一行,并去除重复的行
<select id="selectCodeStr" parameterType="com.xxx.ResourceIndex" resultType="String">
with tmp as (select distinct cate_codes from cbp_resource_index
<where>
<if test="title != null and title != ''">
or title LIKE '%${title}%'
</if>
<if test="keywords != null and keywords != ''">
or keywords LIKE '%${keywords}%'
</if>
<if test="author != null and author != ''">
or author LIKE '%${author}%'
</if>
<if test="cateCodes != null and cateCodes != ''">
AND cate_codes LIKE '%${cateCodes}%'
</if>
<if test="departId != null and departId != ''">
AND depart_id = #{departId}
</if>
</where>
)
SELECT ''+cate_codes+'' FROM tmp FOR XML PATH('')
</select>