Jump to content

order by a value


searls03

Recommended Posts

hi all.  I am looking for a way to order a php query result by a specific value, not like an id ASC, but like first column 1=red(there could be multiples, so all that have column 1 as  red display first), then column2=blue.   

 

I have been looking all day and havent been able to find anything.  any help?

Link to comment
https://forums.phpfreaks.com/topic/281799-order-by-a-value/
Share on other sites

I'm not sure I really understand the question. But, I think you want to sort such that all records where column 1 = red sort first, then by column 2 = blue, etc. If so, the solution is simple, you can create your sorting conditions as comparisons

SELECT *
FROM table_name
ORDER BY column_1 = 'red', column_2='blue'

EDIT: Why is this in the PHP forum? You should know better after 900 posts. Moving to MySQL forum.

Link to comment
https://forums.phpfreaks.com/topic/281799-order-by-a-value/#findComment-1447918
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.