[email protected] Posted October 13, 2007 Share Posted October 13, 2007 my query: SELECT * FROM `table1` UNION ALL SELECT * FROM `table2` ORDER BY `date` desc #1) when i am getting the data using mysql_fetch_array, how can i tell which table the row is from? #2) how can i get everything to order by `date` desc? like right now, that does order it by date desc, except it does the 1st table 1st, the 2nd table 2nd. Link to comment https://forums.phpfreaks.com/topic/73117-mysql-union-question/ Share on other sites More sharing options...
esukf Posted October 13, 2007 Share Posted October 13, 2007 Try:- (SELECT 1 AS tableNo, id, name, date FROM `table1`) UNION ALL (SELECT 2 as tableNo, id, name, date FROM `table2`) order by tableNo ASC, date DESC; You need to list out all the columns. SELECT * won't work. Link to comment https://forums.phpfreaks.com/topic/73117-mysql-union-question/#findComment-368768 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.