dadamssg87 Posted August 21, 2011 Share Posted August 21, 2011 i have this query and i'm trying to order all of the results by `created` ascending. I've tried putting the later query before the first but the single row from the first query(the way it is right now) gets stuck as the last row in the results. How can i order the results of both queries? ( SELECT * FROM Account_activity WHERE DATE( created ) < '2011-08-01' AND username = '40' ORDER BY created DESC LIMIT 1 ) UNION ( SELECT * FROM Account_activity WHERE MONTH( created ) = '08' AND YEAR( created ) = '2011' AND username = '40' ORDER BY created ASC ) Quote Link to comment https://forums.phpfreaks.com/topic/245383-order-rows-of-union-query/ Share on other sites More sharing options...
dadamssg87 Posted August 22, 2011 Author Share Posted August 22, 2011 wow..easy solution ( SELECT * FROM Account_activity WHERE DATE( created ) < '2011-08-01' AND username = '40' ORDER BY created DESC LIMIT 1 ) UNION ( SELECT * FROM Account_activity WHERE MONTH( created ) = '08' AND YEAR( created ) = '2011' AND username = '40' ORDER BY created ASC ) ORDER BY created ASC Quote Link to comment https://forums.phpfreaks.com/topic/245383-order-rows-of-union-query/#findComment-1260363 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.