diff --git a/core/core-backend/src/main/resources/mybatis/ExtVisualizationTemplateMapper.xml b/core/core-backend/src/main/resources/mybatis/ExtVisualizationTemplateMapper.xml
index 2c0591a1f6..7c18f24e46 100644
--- a/core/core-backend/src/main/resources/mybatis/ExtVisualizationTemplateMapper.xml
+++ b/core/core-backend/src/main/resources/mybatis/ExtVisualizationTemplateMapper.xml
@@ -118,18 +118,17 @@
- delete from visualization_template_category_map tcm where tcm.template_id in (
- select id from visualization_template vt
+ delete from visualization_template_category_map tcm
- and vt.name = #{templateName}
-
-
- and vt.template_id = #{templateId}
+ tcm.template_id in (
+ select id from visualization_template vt where vt.name = #{templateName})
+
+ and tcm.template_id = #{templateId}
+
- )