Order results to match the order of values in a WHERE IN expression

前端 未结 6 756
孤街浪徒
孤街浪徒 2021-02-13 03:06

Is there a way I can make mysql return results from a Member database by the order I ask it by in the WHERE command?

SELECT * 
FROM Members 
WHERE MemberID = \"6         


        
6条回答
  •  旧巷少年郎
    2021-02-13 03:39

    no.

    you must specify an ORDER BY clause to get things into any repeatable order.

    If you can construct some logic that specifies the order then you can include that in the ORDER BY otherwise, you cannot.

    You may consider adding another data construct to map your 'random' values to a sequence or other ordering value, then using that.

提交回复
热议问题