Joining tables from two different databases
Posted 21 December 2005 - 05:06 PM
[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] t1.* FROM db1.table1 AS t1, db2.table2 AS t2 WHERE t1.id=t2.id [!--sql2--][/div][!--sql3--]
As simple as that. You can also use JOIN syntax.
or [php] * 1000... PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...
Posted 23 December 2005 - 09:54 PM
Posted 30 December 2005 - 07:15 PM
The inconvenience of having to have similar login credentials to both DBs precludes to use of this technique for any DB that you haven't explicitly set up in this fashion. If it's up to you, keep the related tables in the same DB; if it's not, consider doing this in middleware or via temporary tables, otherwise you'll get caught with your pants down in the credentials ever change!
I suppose the other important issue is making sure there is a common relational key (ID) between the 2 DB tables.
I am always amazed by no matter how much I know, I know I don't know as much as I thought I knew. - D. Brimlow.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users