At 9:56 AM +0100 1/9/01, Luc Van der Veken wrote:
> > From: Frank M. Betz, Jr. [mailto:fbetz@stripped]
>> Sent: Monday 08 January 2001 6:11
>>
>> if that works that's unbelievable. I always thought you
>> could only move
>> data from table to table from the same database not from two
>> different ones.
>> How do you establish a connection to two at the same time
>> through straight
>> SQL?
>
>You have a connection to a server, not to a database, and a server can carry
>more than one database (in fact, most of them should: your own database(s)
>and its own MySQL database with info about databases, tables and users).
>
>I find it unbelievable that in this whole thread, nobody actually tried it
>after that first message ;-)
???
In fact, I did try it before posting my INSERT INTO ... SELECT FROM
example. Your example below (CREATE TABLE ... SELECT FROM) also works,
but only if you have MySQL 3.23 or higher.
>
>mysql> create database test1;
>Query OK, 1 row affected (0.00 sec)
>
>mysql> create database test2;
>Query OK, 1 row affected (0.00 sec)
>
>mysql> use test1;
>Database changed
>mysql> create table test (txt varchar(20));
>Query OK, 0 rows affected (0.02 sec)
>
>mysql> insert into test values('Line1'),('Line2'),('Line3');
>Query OK, 3 rows affected (0.00 sec)
>Records: 3 Duplicates: 0 Warnings: 0
>
>mysql> use test2;
>Database changed
>mysql> create table tst2 select * from test1.test;
>Query OK, 3 rows affected (0.00 sec)
>Records: 3 Duplicates: 0 Warnings: 0
--
Paul DuBois, paul@stripped