Re: join across databases - how to select databases?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: <jeffrey_n_Dyke@Keane.com>
> to my knowledge this is not possible in MySQL.  There are only joins at
the
> table level.  I've been curious about this in the past myself, so if i'm
> incorrect, i'm hoping to hear it via this post.

You can stop hoping now. It is indeed possible. :)

mysql> select * from test1.table1;
+----+------+
| id | name |
+----+------+
|  1 | John |
|  2 | Bill |
|  3 | Mark |
+----+------+
3 rows in set (0.00 sec)

mysql> select * from test2.table2;
+----+---------+
| id | name    |
+----+---------+
|  1 | Holmes  |
|  2 | Foreman |
|  3 | Smith   |
+----+---------+
3 rows in set (0.00 sec)

mysql> select t1.name, t2.name from test1.table1 t1 join test2.table2 t2 on
t1.id = t2.id;
+------+---------+
| name | name    |
+------+---------+
| John | Holmes  |
| Bill | Foreman |
| Mark | Smith   |
+------+---------+
3 rows in set (0.00 sec)

---John Holmes...


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux