应用场景
对于存在多表的模糊或者具体搜索查询,能够根据查询到的id,在关联表里面进行筛选

代码
<select id="search" resultType="cn.datax.service.data.standard.pojo.BaseAssetsMappingPojo">
SELECT sm.* FROM `standard_mapping` sm,`metadata_columns` mc,`standard_codebase` sc
<where>
AND sm.metadata_id=mc.id AND sm.standard_id=sc.id
<if test="map.keywords!= null and map.keywords!=''">
AND (mc.column_ename LIKE CONCAT('%',#{map.keywords},'%')
OR sc.name_ch LIKE CONCAT('%',#{map.keywords},'%'))
</if>
<if test="map.nodeName!= null and map.nodeName!=''">
AND
sm.standard_id IN (SELECT id FROM `standard_codebase` WHERE tree_id IN (
SELECT id FROM `standard_codetree` WHERE parent_id IN (
SELECT id FROM `standard_codetree` WHERE parent_id IN (
SELECT id FROM `standard_codetree` WHERE parent_id IN (
SELECT id FROM `standard_codetree` WHERE parent_id IN (
SELECT id FROM `standard_codetree` WHERE node_name =#{map.nodeName}))))))
</if>
<if test="map.dbName!= null and map.dbName!=''">

本文介绍了如何在Java中使用多表联合查询实现模糊或精确搜索,通过示例展示了如何根据查询参数在标准映射、元数据列和标准代码库表中进行筛选。代码涉及了LIKE操作符、IN子句和递归查询节点名的场景。

1292

被折叠的 条评论
为什么被折叠?



