浏览代码

查询语句优化

zhaops 3 年之前
父节点
当前提交
f8411f3795
共有 2 个文件被更改,包括 12 次插入12 次删除
  1. 6 6
      src/main/resources/mapper/KlConceptMapper.xml
  2. 6 6
      src/main/resources/mapper/KlConceptStaticMapper.xml

+ 6 - 6
src/main/resources/mapper/KlConceptMapper.xml

@@ -546,11 +546,11 @@
 			) t
 			) t
 			LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
 			LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
 			AND l1.is_deleted = 'N'
 			AND l1.is_deleted = 'N'
-			WHERE
-			1=1
+			<where>
 			<if test="inputStr!=null and inputStr!=''">
 			<if test="inputStr!=null and inputStr!=''">
 				AND  LOWER(l1.icd10_code) = LOWER(#{inputStr})
 				AND  LOWER(l1.icd10_code) = LOWER(#{inputStr})
 			</if>
 			</if>
+			</where>
 			UNION
 			UNION
 			SELECT
 			SELECT
 			t.moduleNo,
 			t.moduleNo,
@@ -587,11 +587,11 @@
 			) t
 			) t
 			LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
 			LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
 			AND l1.is_deleted = 'N'
 			AND l1.is_deleted = 'N'
-			WHERE
-			1=1
+			<where>
 			<if test="inputStr!=null and inputStr!=''">
 			<if test="inputStr!=null and inputStr!=''">
 				AND LOWER(l1.icd10_code) LIKE LOWER( concat(#{inputStr},'%'))
 				AND LOWER(l1.icd10_code) LIKE LOWER( concat(#{inputStr},'%'))
 			</if>
 			</if>
+			</where>
 			UNION
 			UNION
 			SELECT
 			SELECT
 			t.moduleNo,
 			t.moduleNo,
@@ -628,11 +628,11 @@
 			) t
 			) t
 			LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
 			LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
 			AND l1.is_deleted = 'N'
 			AND l1.is_deleted = 'N'
-			WHERE
-			1=1
+			<where>
 			<if test="inputStr!=null and inputStr!=''">
 			<if test="inputStr!=null and inputStr!=''">
 				AND LOWER(l1.icd10_code) LIKE LOWER( concat('%',#{inputStr},'%'))
 				AND LOWER(l1.icd10_code) LIKE LOWER( concat('%',#{inputStr},'%'))
 			</if>
 			</if>
+			</where>
 		</if>)o1
 		</if>)o1
 		order  by o1.type asc,o1.moduleNo ASC,o1.isConcept DESC
 		order  by o1.type asc,o1.moduleNo ASC,o1.isConcept DESC
 		Limit 1000
 		Limit 1000

+ 6 - 6
src/main/resources/mapper/KlConceptStaticMapper.xml

@@ -349,11 +349,11 @@
             ) t
             ) t
             LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
             LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
             AND l1.is_deleted = 'N'
             AND l1.is_deleted = 'N'
-            WHERE
-            1=1
+            <where>
             <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
             <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
                 AND LOWER(l1.icd10_code) = LOWER(#{staticKnowledgeIndexPageVO.inputStr})
                 AND LOWER(l1.icd10_code) = LOWER(#{staticKnowledgeIndexPageVO.inputStr})
             </if>
             </if>
+            </where>
             UNION
             UNION
             SELECT
             SELECT
             t.moduleNo,
             t.moduleNo,
@@ -390,11 +390,11 @@
             ) t
             ) t
             LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
             LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
             AND l1.is_deleted = 'N'
             AND l1.is_deleted = 'N'
-            WHERE
-            1=1
+            <where>
             <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
             <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
                 AND LOWER(l1.icd10_code) LIKE LOWER( concat(#{staticKnowledgeIndexPageVO.inputStr},'%'))
                 AND LOWER(l1.icd10_code) LIKE LOWER( concat(#{staticKnowledgeIndexPageVO.inputStr},'%'))
             </if>
             </if>
+            </where>
             UNION
             UNION
             SELECT
             SELECT
             t.moduleNo,
             t.moduleNo,
@@ -431,11 +431,11 @@
             ) t
             ) t
             LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
             LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
             AND l1.is_deleted = 'N'
             AND l1.is_deleted = 'N'
-            WHERE
-            1=1
+            <where>
             <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
             <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
                 AND LOWER(l1.icd10_code) LIKE LOWER( concat('%',#{staticKnowledgeIndexPageVO.inputStr},'%'))
                 AND LOWER(l1.icd10_code) LIKE LOWER( concat('%',#{staticKnowledgeIndexPageVO.inputStr},'%'))
             </if>
             </if>
+            </where>
         </if>
         </if>
         ) s,
         ) s,
         kl_concept_static s1
         kl_concept_static s1