美文网首页
mybatis 下 mysql in查询按照参数顺序输出结果

mybatis 下 mysql in查询按照参数顺序输出结果

作者: 爱的旋转体 | 来源:发表于2018-03-14 21:32 被阅读0次

使用Field函数:

<select id="findByIds"  resultType="com.bwhx.eruler.bean.CeliangBuwei">  
    SELECT * FROM project_celiangbuwei  where  clbwid in   
    <foreach collection="array" index="index" item="item" open="(" separator=","  close=")" >  
        #{item}    
      </foreach>   
      order by   
      field(  
      clbwid,  
      <foreach collection="array" index="index" item="item"   separator=","    >  
        #{item}    
      </foreach>   
      )  
</select>  

相关文章

网友评论

      本文标题:mybatis 下 mysql in查询按照参数顺序输出结果

      本文链接:https://www.haomeiwen.com/subject/aqvqqftx.html