MySQLユーザーは
、パラメーターの長さを制限することなく、field(value1、id1、id2、id3、...)によって独自のソート関数の順序を定義します。
意味:取得した値をid1、id2、id3の順序に従って並べ替えます...
例:mybatis
select
<include refid="Base_Column_List"/>
from tb_newbee_mall_goods_info
where goods_id in
<foreach item="id" collection="list" open="(" separator="," close=")">
#{
id}
</foreach>
order by field(goods_id,
<foreach item="id" collection="list" separator=",">
#{
id}
</foreach>
);
mybatisで渡されるパラメーターはidのList配列であり、この配列の順序はすでに配置されており、mybatisは同じ順序でデータを返す必要があります。