当前位置:Gxlcms > 数据库问题 > sql片段的定义

sql片段的定义

时间:2021-07-01 10:21:17 帮助过:2人阅读

sql片段 id 表示唯一标示 这里不加where是因为 sql片段只对单表查询才抽取出来 这样的重用性更高 --> <sql id="query_user_where"> <if test="userCustom!=null"> <if test="userCustom.username != null and userCustom.username !=‘‘"> user.username like(‘%${userCustom.username}%‘) </if> </if> <!-- and(id=3 or id=6 or id=7) --> <!-- collection包装对象的属性 item 集合属性的单个对象 open 拼接开始字符串 close 拼接结束字符串 separator 每次遍历中间的分割字符串--> <foreach collection="ids" item="id" open="and(" close=")" separator="or"> id=#{id} </foreach> </sql>

 

sql片段的定义

标签:

人气教程排行