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
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.

Edited by Psycho
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.