mybatis sql in 查询(mybatis sql语句传入参数是list)mybatis中使用in查询时in怎么接收值
2016-12-16 21:11
831 查看
1.in查询条件是list时
.1 如果参数的类型是List, 则在使用时,collection属性要必须指定为 list
<select id="findByIdsMap" resultMap="BaseResultMap">
Select
<include refid="Base_Column_List" />
from jria where ID in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>
2.in查询条件是枚举值时
默认下,使用select xxx where in(xx,xx)查询,返回结果是按主键排序的,如果要按in()中值的排列顺序,可以这样做:
select * from talbe where id in(3,2,4,1) ORDER BY FIND_IN_SET( id, '3,2,4,1')
<select id="getMultiMomentsCommentsCounts" resultType="int"> select moment_comment_count from tbl_moment_commentCount where mid in <foreach item="item" index="index" collection="list" open="(" separator="," close=")"> #{item} </foreach> </select>
.1 如果参数的类型是List, 则在使用时,collection属性要必须指定为 list
<select id="findByIdsMap" resultMap="BaseResultMap">
Select
<include refid="Base_Column_List" />
from jria where ID in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>
2.in查询条件是枚举值时
默认下,使用select xxx where in(xx,xx)查询,返回结果是按主键排序的,如果要按in()中值的排列顺序,可以这样做:
select * from talbe where id in(3,2,4,1) ORDER BY FIND_IN_SET( id, '3,2,4,1')
相关文章推荐
- Mybatis中的SQL语句中的IN子句使用传入List作为包含条件
- 两种使用nuzt接收动态参数编写SQL语句进行分页查询
- Mybatis查询实例,sql中的in在Mybatis中怎么写--以list为查询条件
- Mybatis查询实例,sql中的in在Mybatis中怎么写--以list为查询条件
- 使用SQL查询语句时,数组动态赋值SQL IN ()作为条件条件一个
- Web Sql Database 操作类,将查询语句作为参数传入。
- Mybatis进行id类型、String类型、map类型、ben类型参数传入Sql查询
- Mybatis中sql语句中的in查询,一定要判断null的情况
- Web Sql Database 操作类,将查询语句作为参数传入。
- Sql语句中in(...)使用参数变量
- Mybatis中sql语句中的in查询,一定要判断null的情况
- mybatis 使用一个参数传递数值 sql主要是使用到 in
- mybatis下oracle查询语句where xxx in(aa,bb)的使用方式
- Mybatis中sql语句中的in查询,一定要判断null的情况
- 根据参数指定的列名和值查询员工信息(使用动态sql语句)
- MyBatis动态SQL使用,传入参数Map中的Key判断
- Mybatis中sql语句中的in查询,一定要判断null的情况
- IBatis.Net中既有In查询又有其他参数传入,怎么办
- 【转】使用sp_executesql执行动态SQL语句,同时向里面传入参数。
- Mybatis中如何在SQL语句表名中使用参数