mybatis中的写法

<select id="selectByIds"     
                resultType="com.hoohui.electronic.util.ExHashMap">
        select
        <include refid="Base_Column_List" />
        from doctor t where t.id in
        <foreach item="item" index="index" collection="array"
                 open="(" separator="," close=")">
        #{item}
        </foreach>
        order by field(id,
        <foreach item="item" index="index" collection="array"
                 open="" separator="," close="">
            #{item}
        </foreach>
        )
    </select>        

mysql语句的写法

SELECT  *  FROM  `doctor`  WHERE  id  IN(580,579,578,577,576,575,574,573,543,305,321,340,388,402,433)  ORDER  BY  INSTR(',580,579,578,577,576,575,574,573,543,305,321,340,388,402,433,',CONCAT(',',id,','))

 

select * from table where id IN (3,6,9,1,2,5,8,7) order by field(id,3,6,9,1,2,5,8,7); 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-24
  • 2021-12-29
  • 2021-12-28
  • 2022-01-15
  • 2021-06-18
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案