The most convenient way to do this (especially if you do this query a lot) would be to create a View, but it's not supported until MySQL 5.01.
There are a bunch of good comments on this page that should get you squared away. UNION is a little buggy pre-MySQL 4.1... check out the workarounds. http://dev.mysql.com/doc/mysql/en/union.html It would also be useful to know your MySQL server version and your schema. Just as friendly advice, I'm not going to spend a bunch of time setting up test databases when I could just cut and paste your schema. It would be even nicer if you included a couple INSERTS with test records... Either way, I think the comments in the manual will get you squared away. Just to sate my personal curiosity, I'd love to know why those databases are separate but equal. Good luck, Jeromie >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/
