How about:
insert into table3(company_id,lev_id,vare_id)
(select table2.company_id,lev_id,vare_id
from table1, table2
where table1.company_id = table2.company_id);
Scott Canaan ([EMAIL PROTECTED])
(585) 475-7886
"Life is like a sewer, what you get out of it depends on what you put into it." - Tom
Lehrer.
-----Original Message-----
Sent: Thursday, October 16, 2003 10:20 AM
To: Multiple recipients of list ORACLE-L
Hallo,
Anyone whom could g�ve me some good help on this.
I have a table with one field, called Company_id
Like this
Company_id
16
45
50
In table 2 I have this field and values:
Company_id Lev_id Vare_id
16 45 56
34 10 20
67 10 20
45 15 30
50 12 12
I would like to from table 2 do a select and find the Company_ids from table1 and find
out the responding lev_id and vare_id in table2and then insert them into a new
table(table3) so it would look like this:
Company_id Lev_id Vare_id
16 45 56
Anyone whom could give me some help on this how to write the sql- query.
I have tried with this sql query. What is wrong?
insert into table3(company_id,lev_id,vare_id)
select company_id,lev_id,vare_id from table2 where vare_id = 56
(where exists select company_id from table1)
Thanks in advance
Roland
--
Please see the official ORACLE-L FAQ: http://www.orafaq.net
--
Author:
INET: [EMAIL PROTECTED]
Fat City Network Services -- 858-538-5051 http://www.fatcity.com
San Diego, California -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).
--
Please see the official ORACLE-L FAQ: http://www.orafaq.net
--
Author: Scott Canaan
INET: [EMAIL PROTECTED]
Fat City Network Services -- 858-538-5051 http://www.fatcity.com
San Diego, California -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).