22 messages in com.mysql.lists.win32RE: SQL...
FromSent OnAttachments
Steve Mills06 Jan 2001 15:52 
John Dean07 Jan 2001 01:33 
jed07 Jan 2001 02:20 
"Nyström, Rasmus"07 Jan 2001 08:42 
Frank M. Betz, Jr.07 Jan 2001 21:10 
jed07 Jan 2001 23:50 
Paul DuBois08 Jan 2001 07:45 
Nick Tentomas08 Jan 2001 08:19 
jed08 Jan 2001 09:47 
Tim Endres08 Jan 2001 11:30 
Paul DuBois08 Jan 2001 13:50 
Paul DuBois08 Jan 2001 16:38 
Paul DuBois08 Jan 2001 16:39 
Luc Van der Veken09 Jan 2001 00:56 
jed09 Jan 2001 03:37 
Stephen Woodbridge09 Jan 2001 06:16 
jed09 Jan 2001 06:28 
Paul DuBois09 Jan 2001 06:29 
Paul DuBois09 Jan 2001 06:30 
jed09 Jan 2001 07:00 
Luc Van der Veken09 Jan 2001 23:47 
jed09 Jan 2001 23:52 
Subject:RE: SQL...
From:Paul DuBois (pa@snake.net)
Date:01/09/2001 06:29:41 AM
List:com.mysql.lists.win32

At 9:56 AM +0100 1/9/01, Luc Van der Veken wrote:

From: Frank M. Betz, Jr. [mailto:fbe@ltis.net] 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