本文介绍了排序结果以匹配WHERE IN表达式中值的顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一种方法可以使Wmysql按照我在WHERE命令中要求的顺序从成员数据库返回结果?
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"
OR MemberId="3"
OR MemberID="5"
当前,无论我做什么,它都将返回由MemberID ASC排序的结果.我希望它能按我要求的顺序在6,3,5之前返回.
Currently it will return results ordered by MemberID ASC no matter what I do. I want it to return by 6,3,5 i.e. in the order that I ask it.
推荐答案
Select * from Members
WHERE MemberID = "6" or MemberId="3" or MemberID="5"
ORDER BY MemberID = "6" DESC, MemberId="3" DESC, MemberID="5" DESC;
这篇关于排序结果以匹配WHERE IN表达式中值的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!