If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Is this possible

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-08-04, 23:01
thesandman thesandman is offline
Registered User
 
Join Date: Jul 2004
Posts: 6
Question Is this possible

I want to join tables from 2 different databases.
I have a table in 1 db in which i want to join with in another table in abother db.

Can this be done and what is the syntax?
Thanks
Rich
Reply With Quote
  #2 (permalink)  
Old 07-09-04, 00:01
jvanv8 jvanv8 is offline
Registered User
 
Join Date: Feb 2004
Posts: 7
INSERT INTO `dbname1`.`table1` (row1,row2)
SELECT row1,row2 FROM `dbname2`.`table2`
WHERE row1 > 5;

would be an example.

- John
Reply With Quote
  #3 (permalink)  
Old 07-09-04, 12:05
bstjean bstjean is offline
Registered User
 
Join Date: Sep 2002
Location: Montreal, Canada
Posts: 219
Quote:
Originally Posted by thesandman
I want to join tables from 2 different databases.
I have a table in 1 db in which i want to join with in another table in abother db.

Can this be done and what is the syntax?
Thanks
Rich
You just need to prefix the tablename with the database name, for example:

select a.col1, b.col2
from database1.tablename a
inner join database2.tablename b on (a.id=b.id)
where b.col2 = 33
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On