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

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

RE: Question about sql

From: Scott Canaan <srcdco_at_rit.edu>
Date: Thu, 16 Oct 2003 06:44:41 -0800
Message-ID: <F001.005D35FE.20031016064441@fatcity.com>


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 (srcdco_at_rit.edu)
(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: 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).
--

Please see the official ORACLE-L FAQ: http://www.orafaq.net
--

Author: Scott Canaan
  INET: srcdco_at_rit.edu
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:44:41 CDT

Original text of this message

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