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
Get mysql info in 2 different database
Moderator: General Moderators
- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
have a read of the second paragraph and code sample at this page: http://www.mysql.com/doc/en/USE.html
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
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;