這篇文章主要介紹了詳解 mysql查詢結果順序按 in() 中id 的順序排列的相關資料,希望通過本文能幫助到大家,需要的朋友可以參考下
詳解 mysql查詢結果順序按 in() 中ID 的順序排列
實例代碼:
<select>? ????select?style_num_id?,style_id,style_title,style_pic?FROM?gb_style?where?online?=?1?AND?is_hide?=?0?and?style_num_id?in? ????<foreach>? ?????#{styleNumId}? ????</foreach>? ????ORDER?BY?FIELD? ????<foreach>? ??????#{styleNumId}? ????</foreach>? ??</select>
最終輸出sql如下:
select?style_num_id?,style_id,style_title,style_pic?FROM?gb_style?where?online?=?1?AND?is_hide?=?0?and?style_num_id?in?(1,3,2,5)? order?by?field?(style_num_id,1,3,2,5);
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END