MySQL Forums
Forum List  »  InnoDB

Re: maintain result set order with WHERE IN clause
Posted by: William Chiquito
Date: May 23, 2008 08:26PM

Hi Jesse,

An option is:
SELECT * FROM tbl_name WHERE column_a IN ( val1, val2, val3 )
ORDER BY column_a = val1 DESC, column_a = val2 DESC, column_a = val3 DESC;
Or
SELECT * FROM tbl_name WHERE column_a IN ( val1, val2, val3 )
ORDER BY FIELD(column_a, val1, val2, val3);



Edited 1 time(s). Last edit at 05/23/2008 08:50PM by William Chiquito.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: maintain result set order with WHERE IN clause
4688
May 23, 2008 08:26PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.