Mysql query results are ordered by IDS in (). mysql query results
Mysql query results are ordered by IDS in ().
Instance code:
<Select id = "queryGBStyleByIDs" resultMap = "styleMap"> 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 collection = "styleNumIDs" item = "styleNumId" separator = "," open = "(" close = ") ">#{ styleNumId} </foreach> order by field <foreach collection =" styleNumIDs "item =" styleNumId "separator =", "open =" (style_num_id, "close =") ">#{ styleNumId} </foreach> </select>
The final output SQL statement is as follows:
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 (,) order by field (style_num_id );
If you have any questions, please leave a message or go to the community on this site for discussion. Thank you for reading this article. Thank you for your support!