引言
include标签用法是引用sql片段
sql标签 是书写sql片段 被include 引用的
<sql id="query_where"> <where> excel_file_id = #{excelFileId} <if test="field1 != null"> AND field1 = #{field1} </if> <if test="field2 != null"> AND field2 = #{field2} </if> <if test="field3 != null"> AND field3 = #{field3} </if> </where> </sql>
引用
SELECT * FROM t_excel_file_detail <include refid="query_where"></include>