insert into table3(company_id,lev_id,vare_id)
    select company_id,lev_id,vare_id from table2 where vare_id = 56
    AND exists (select  1  from table1 where table1.company_id =
table2.company_id)

On Thu, 2003-10-16 at 10:20, [EMAIL PROTECTED] wrote:
> 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
Richard Quintin, DBA 
Information Systems & Computing, DBMS 
Virginia Tech 
-- 
"Living in the moment brings you a sense of reverence for all of life's
blessings." -- Oprah Winfrey
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Quintin, Richard
  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).

Reply via email to