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

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

    SELECT 
      * 
    FROM 
      Members 
    WHERE 
      MemberID IN ("6","3","5")
    ORDER BY 
      FIELD(MemberID,"6","3","5");
    

提交回复
热议问题