Mybatis实现in查询(注解形式和xml形式)1. @Select注解中使⽤in
@Select({"<script> " +
" select * "+
" from business_threat bt \n" +
" join abnormal_event_type aet on bt.event_type_id = aet.id " +
" where1=1 " +
" <if test = \" ids !=null \"> " +join和in哪个查询更快
" and bt.id in " +
" <foreach item ='item'index='index' collection ='ids'open='(' separator =','close=')'> " +
" #{item} " +
" </foreach> " +
" </if> " +
"</script>"})
List<BusinessThreatVO> getByBusinessThreadId(@Param("ids") List<Long> ids);
2. xml中使⽤in
<select id="findByModelInMarket" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from device
WHERE replace(lower(model_in_market), ' ', '') = replace(lower(#{modelInMarket}), ' ', '')
AND status IN <foreach collection="deviceStatus" item="status" open="(" close=")" separator=",">#{status}</foreach>
</select>

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。