List:General Discussion« Previous MessageNext Message »
From:Christian Mack Date:August 12 1999 9:30pm
Subject:Re: select into table...
View as plain text  
"Geocrawler.com" wrote:
> 
> How can I insert data from multiple tables into another table?
> 
> the source tables are 3 different tables...
> example:
> I want col1 of table1 in col1 of the target-table, col6 of table2 in col2 of the
> target-table and col3 of table3 in col3 of the target-table...
> 
> I tried this:
> 
> insert into table dest (col1, col2, col3) SELECT col1 from table1, select col6 from
> table2, select col3 from table3;
> 
> How can I get the data in that table?
> 
> regards, Martin

Hi Martin

Just use:
INSERT INTO TABLE 
	dest 
	(col1, col2, col3) 
SELECT 
	a.col1
	, b.col2
	, c.col3 
FROM 
	table1 AS a
	,table2 AS b
	,table3 AS c
WHERE
	a.ID = b.ID
	AND b.ID = c.ID
;

Perhaps you need to use LEFT JOIN instead of the JOIN kommatas.
Certainly you will change the WHERE part to something useful in your case :)

Tschau
Christian

Thread
select into table...Geocrawler.com12 Aug
  • Re: select into table...Thimble Smith12 Aug
  • Re: select into table...Christian Mack12 Aug