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
Try this:
SELECT * FROM Members
ORDER BY CASE MemberId
WHEN 6 THEN 1
WHEN 3 THEN 2
WHEN 5 THEN 3
ELSE 999
END
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?
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.
SELECT
*
FROM
Members
WHERE
MemberID IN ("6","3","5")
ORDER BY
FIELD(MemberID,"6","3","5");
Try selecting the data using 3 UNION ALL
queries:
SELECT * FROM Members WHERE MemberID = "6"
UNION ALL
SELECT * FROM Members WHERE MemberId = "3"
UNION ALL
SELECT * FROM Members WHERE MemberID = "5"
or maybe you need to simply add a new column to hold the sort order ?
Select * from Members
WHERE MemberID = "6" or MemberId="3" or MemberID="5"
ORDER BY MemberID = "6" DESC, MemberId="3" DESC, MemberID="5" DESC;