Page 1 of 1
Get mysql info in 2 different database
Posted: Mon Jan 06, 2003 7:24 pm
by seontay
I have a problem to retrieve a data from 2 different table in 2 different database. How to link it in single mysql query statement? Please help.
Thank you
Freddie
Posted: Mon Jan 06, 2003 10:49 pm
by mydimension
have a read of the second paragraph and code sample at this page:
http://www.mysql.com/doc/en/USE.html
Posted: Tue Jan 07, 2003 2:47 am
by seontay
But in PHP we must link the 2 different database before perform the query. I try few times it still fail, How the correct statement look like? somebody please help.

Posted: Tue Jan 07, 2003 3:49 am
by twigletmac
Depending on what exactly you want to do you could:
- use mysql_select_db() to select the first database, query that then use mysql_select_db() to switch to the second database so that you can query it, or
- use this type of syntax in your SQL statement (as shown in the page mydimension linked you to):
Code: Select all
SELECT author_name,editor_name FROM author,db2.editor WHERE author.editor_id = db2.editor.editor_id;
Mac