定义常量:
sql与include标签
sql标签和include标签一般是一起使用的,sql标签中id属性对应include标签中的refid属性。通过include标签将sql片段和原sql片段进行拼接成一个完整的sql语句进行执行。sql标签可以用来定义可复用的sql代码片段,可以通过include标签包含在其他语句中。
如:
<sql id="user"> id,username,password</sql>
<select id="selectUsers" resultType="map">
select
<include refid="user" />
from table
</select>
拼接起来就是:
<select id="selectUsers" resultType="map">
select
id, username,password
from table
</select>








网友评论