Re: join across databases - how to select databases?
| From: | CPT John W. Holmes | Date: | Fri, 22 Aug 2003 15:37:33 +0000 |
| Subject: | Re: join across databases - how to select databases? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-30055@lists.php.net to get a copy of this message | ||
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...