Sql query to Join tables between two database
by Mohan[ Edit ] 2014-03-07 11:47:56
Join tables between two database
Simple sql query to join two tables of two databses.
Database1
tablename:user
id Name
1 Jack
3 Jim
5 Mary
7 Sue
8 Ron
9 Phil
Databse2
tablename:user
id Name
1 Jack
2 Creed
3 Jim
4 Dave
5 Mary
6 Bob
The below sql query will join the 2 tables based on the primary id and only return records for the first user table if a match is found in the second user table.
SELECT u1.* FROM database1.user u1 LEFT JOIN database2.user u2 ON u1.id=u2.id WHERE u2.id IS NOT NULL;
MANIMUTHUPANDI
Useful one
0
0
Add Reply