Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Question about sql

Question about sql

From: <roland.skoldblom_at_ica.se>
Date: Thu, 16 Oct 2003 06:20:05 -0800
Message-ID: <F001.005D35F2.20031016062005@fatcity.com>


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: roland.skoldblom_at_ica.se

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: ListGuru_at_fatcity.com (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). Received on Thu Oct 16 2003 - 09:20:05 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US