Canman2005 Posted May 2, 2010 Share Posted May 2, 2010 Hi all I have the following database table ID VALUE 1 Apple 2 Microsoft 3 Mobiles 4 MP3s 5 Laptops I use a "SELECT" query in my PHP to get those results. Is it possible to "ORDER" my results by ID number 2 first ID number 1 second and then the remainder of the results in a A-Z order so the above would look like ID VALUE 2 Microsoft 1 Apple 5 Laptops 3 Mobiles 4 MP3s I tried ORDER BY (CASE WHEN `id` = 2 THEN 0 WHEN `id` = 1 THEN 2 END), `value` ASC But that doesn't seem to work no matter how much I tweak it around Any help would be great Thanks Ed Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 2, 2010 Share Posted May 2, 2010 What difference would that make? You can easily add a new column called "ordering" if you want to order them in a particular order. You can still do it using UNION. Just select the first 2 in descending order, then UNION it with the rest ordered by descending. Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted May 2, 2010 Author Share Posted May 2, 2010 It's just that I want to show some rows at the top of the list. I guess if it's not easy i'll have to think of another route Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 2, 2010 Share Posted May 2, 2010 It is easy. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.