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

前端 未结 6 781
孤街浪徒
孤街浪徒 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:32

    Try this

    Select * from Members WHERE MemberID = "6" or MemberId="3" or MemberID="5" order by 
    MemberID = "6" desc 
    MemberId="3" desc
    MemberID="5" desc
    

    See this post once

    How to make MYSQL query results ORDER BY conditions order?

提交回复
热议问题