mameha Posted October 15, 2007 Share Posted October 15, 2007 I have some user records stored in two tables. The table structure is identical. table1 = latest data table2 = archived data (once a month the latest data is added to the archived data). Question: How to select data from BOTH tables at once? I tried this but it failed: SELECT `lastname` , `firstname` , `email` FROM `table1` , `table2` WHERE `country` = 'CN' Link to comment https://forums.phpfreaks.com/topic/73280-how-to-select-data-from-two-identical-tables/ Share on other sites More sharing options...
Barand Posted October 15, 2007 Share Posted October 15, 2007 Use a UNION, not a JOIN SELECT `lastname` , `firstname` , `email` FROM `table1` WHERE `country` = 'CN' UNION SELECT `lastname` , `firstname` , `email` FROM `table2` WHERE `country` = 'CN' Link to comment https://forums.phpfreaks.com/topic/73280-how-to-select-data-from-two-identical-tables/#findComment-369773 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.