Home » SQL & PL/SQL » SQL & PL/SQL » inserting data into single table from multiple tables
inserting data into single table from multiple tables [message #20436] Thu, 23 May 2002 09:47 Go to next message
ckr
Messages: 13
Registered: May 2002
Junior Member
hai,
i just want to know how to create single table from multiple tables.
i have two tables customers and orders related by cust_id. i used the following query.

create table custcopy2 as select cust_id,cust_name,order_num
from customers c,orders o
where c.cust_id=o.cust_id;

result....column ambigously defined.
Re: inserting data into single table from multiple tables [message #20439 is a reply to message #20436] Thu, 23 May 2002 11:40 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
The cust_id column exists in both tables so you need to prefix that column reference with the alias. In general for multi-table queries, I recommend prefixing every column (even those that are not ambigously referenced) with a table alias.

create table custcopy2 as
select c.cust_id, c.cust_name, o.order_num
  from customers c,orders o
 where c.cust_id = o.cust_id;
Previous Topic: Count of unique values of a field in a table.
Next Topic: sys_guid
Goto Forum:
  


Current Time: Thu Mar 28 12:59:49 CDT 2024