MySQL Table Join with Different Databases

I'm trying to give an example how to join 2 tables from different database using MySQL.
Here is a query sample:

SELECT database1.namatabel1.namafieldtabel1,
       database1.namatabel1.namafieldtabel2 
FROM   database1.namatabel1 
       INNER JOIN database2.namatabel2 ON 
             database1.namatabel1.fieldkunci = 
             database2.namatabel2.fieldkunci

And this one is a sample using table alias.
SELECT A.namafieldtabel1, B.namafieldtabel2 
FROM   database1.namatabel1 A
       INNER JOIN database2.namatabel2 B ON 
             A.fieldkunci = B.fieldkunci

may be useful :)

Click here if you like this article.


Post a Comment

0 Comments