I'd guess you got all from table a and two from table b Might have to use a temp table to work this out.
Eg. Get the top two from table a, into the temp table, Then the top two from table b into the same temp table then get the top two out of the temp table. Pat -----Original Message----- From: Hendra Susanto [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 15, 2005 10:38 PM To: [email protected] Subject: [php_mysql] merge select from 2 table i have 2 table: TableA Name Birth Sandra Jan 1,1980 Bob Feb 12,1972 TableB Name Birth Hendra Jan 4,1950 Joeli Feb 15,1962 How do i select the oldest 2 people from both table in php??? I've tried: <?php $statement = "(SELECT name FROM TableA) UNION (SELECT name FROM TableB) LIMIT 2 ORDER BY Birth"; $result = mysql_query($statement); while ($row = mysql_fetch_array($result)) echo $row[name]; ?> but it didn't work.. any other solution?? Each table contains about 50.000 records, and i have a perfect good reason to keep them in a separate table. The PHP_mySQL group is dedicated to learn more about the PHP_mySQL web database possibilities through group learning. Yahoo! Groups Links The PHP_mySQL group is dedicated to learn more about the PHP_mySQL web database possibilities through group learning. Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/php_mysql/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
