MySQL Forums
Forum List  »  Merge Storage Engine

Re: Problems with UNION and ORDER BY
Posted by: steve ralph
Date: January 23, 2008 05:38PM

Hi just to let you know that I have solved the problem

I Just placed tm from the AS clause into the ORDER BY at the end of the query. Seems to work fine now.

DATE_FORMAT(db1.tbl1.tbl_date, '%M %d, %Y') AS tm

$query = "(SELECT CONCAT(a_item1) AS i1, (a_item2) AS i2, (a_item3) AS i3, DATE_FORMAT(db1.tbl1.tbl_date, '%M %d, %Y') AS tm FROM db1.tbl1, db1.tbl2 WHERE status = '6' AND tbl1_ID = tbl2_ID ORDER BY db1.tbl1.tbl_date DESC LIMIT 6)
UNION ALL
SELECT CONCAT(b_item1) AS i1, (b_item2) AS i2, (b_item3) AS i3, DATE_FORMAT(db2.tbl1.tbl_date, '%M %d, %Y') AS tm FROM db2.tbl1, db2.tbl2 WHERE status = '6' AND tbl1_ID = tbl2_ID ORDER BY db2.tbl1.tbl_date DESC LIMIT 6) ORDER BY tm DESC LIMIT 6";

Options: ReplyQuote


Subject
Views
Written By
Posted
20753
January 22, 2008 05:48PM
Re: Problems with UNION and ORDER BY
9405
January 23, 2008 05:38PM
7937
January 23, 2008 06:43PM


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.