Hi all, I want to sort some sql results by a certain list. I don't want it sorted alphabetically or anything. I want to specify a certain list. eg "order by `office` = 'president', 'vise President', secretery'" ect. Is there anyway to do this? I didn't type this example exactly how I want it nor have I tried it. I think it gets my point across though. I appreciate any help.
PomonaGrange
0
Junior Poster in Training
Recommended Answers
Jump to PostThis would be a subquery in your larger query:
(SELECT CASE WHEN `office` = 'president' THEN 1 CASE WHEN `office` = 'vice-president' THEN 2 CASE WHEN `office` = 'secretary' THEN 3 # fill in the rest ELSE 4 END) as sort
where sort is the alias we've …
All 3 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.