作者 朱兆平

消息分类查询搜索sql优化

@@ -44,18 +44,21 @@ @@ -44,18 +44,21 @@
44 <include refid="Base_Column_List" /> 44 <include refid="Base_Column_List" />
45 from message_type 45 from message_type
46 <where> 46 <where>
  47 + <if test="name == null or name == ''">
  48 + parent_id = 0
  49 + </if>
47 <if test="id != null and id != ''"> 50 <if test="id != null and id != ''">
48 and ID = #{id,jdbcType=VARCHAR} 51 and ID = #{id,jdbcType=VARCHAR}
49 </if> 52 </if>
50 - <if test="name != null and name != ''">  
51 - and name = #{name,jdbcType=VARCHAR}  
52 - </if>  
53 <if test="type !=null and type > 0"> 53 <if test="type !=null and type > 0">
54 and type = #{type,jdbcType=INTEGER} 54 and type = #{type,jdbcType=INTEGER}
55 </if> 55 </if>
56 <if test="des != null and des != ''"> 56 <if test="des != null and des != ''">
57 and des like concat('%',#{des,jdbcType=VARCHAR},'%') 57 and des like concat('%',#{des,jdbcType=VARCHAR},'%')
58 </if> 58 </if>
  59 + <if test="name != null and name != ''">
  60 + and name = #{name,jdbcType=VARCHAR}
  61 + </if>
59 </where> 62 </where>
60 </select> 63 </select>
61 <delete id="deleteByPrimaryKey" parameterType="java.lang.String" > 64 <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >