EagerWolf Posted May 29, 2008 Share Posted May 29, 2008 Hi! I am looking for salvation for my complex data ordering in MySQL. I have options: price (price in EURos) and price_1 (ENUM - 0, 1) Example: case1: price = 1400 price_1 = 0 case2: price = 1400 price_1 = 1 case3: price = NULL price_1 = 1 If is price_1 = 0 and price = 1400, than it is printed: 1400 $ The point is if is set price_1 = 1 and is set price (1400), than it is shown like this: Call for price (cca 1400). If price_1 = 1 and price = NULL, than it is printed just Call for price. And what I want to set is that values with price 0 or NULL are listed in the end of results. Let us say we have table like this: ID price price_1 1 1400 1 2 0 1 3 1200 1 4 1300 0 5 800 0 I want output to list me records in order by price with price = 0 in the end. So the proper order would be (by IDs): 5, 3, 4, 1, 2 And records must be stored in the same query... I don't want to make two queries for this. Thanks for your help! Quote Link to comment https://forums.phpfreaks.com/topic/107855-complex-order/ Share on other sites More sharing options...
Barand Posted May 29, 2008 Share Posted May 29, 2008 ... ORDER BY price=0, price Quote Link to comment https://forums.phpfreaks.com/topic/107855-complex-order/#findComment-553032 Share on other sites More sharing options...
EagerWolf Posted May 30, 2008 Author Share Posted May 30, 2008 So query would be: SELECT * FROM table ORDER by price=0, price Quote Link to comment https://forums.phpfreaks.com/topic/107855-complex-order/#findComment-553459 Share on other sites More sharing options...
EagerWolf Posted June 4, 2008 Author Share Posted June 4, 2008 Any idea? Quote Link to comment https://forums.phpfreaks.com/topic/107855-complex-order/#findComment-557544 Share on other sites More sharing options...
Barand Posted June 4, 2008 Share Posted June 4, 2008 SELECT * FROM table ORDER by price=0, price Are you waiting for someone to run the query for you? Quote Link to comment https://forums.phpfreaks.com/topic/107855-complex-order/#findComment-557640 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.