<choose><when><if>
--说明:choose类似于switch,其中的when如果不符合则进入otherwise(类似于default),可以结合if标签使用。 -- <select> -- SELECT * -- FROM [TABLE_NAME] AS [...] -- GROUP BY [COLUMN_NAME],[COLUMN_NAME],...... -- WHERE 1=1 -- <if test="['']!=null and ['']!=''"> -- and [""] = [""] -- </if> -- <choose> -- <when test="['传入的参数/COLUMN_NAME']!=null AND ['传入的参数/COLUMN_NAME']!='' "> -- AND [COLUMN_NAME] >= to_date(#{anatimebegin},'yyyy/mm/dd') -- AND [COLUMN_NAME] < to_date(#{anatimeend},'yyyy/mm/dd')+1 -- </when> -- <when test="anatimeend!=null and anatimeend!=''"> -- AND [COLUMN_NAME] < to_date([COLUMN_NAME],'yyyy/mm/dd')+1 -- </when> -- </choose> -- order by [COLUMN_NAME] -- </select>