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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Help inserting values into table using a subquery

Re: Help inserting values into table using a subquery

From: Karsten Farrell <kfarrell_at_belgariad.com>
Date: Fri, 07 Feb 2003 00:38:03 GMT
Message-ID: <MPG.18ac9fc174ed3d498968b@news.la.sbcglobal.net>


d_newsham_at_hotmail.com said...
> Hi,
>
> I need to match up a column in two of my tables. Running the
> following query:
>
> select id from table1
> where id not in (select id from table2))
>
> returns 44 rows. I need to have table2 contain the exact same number
> of rows and id numbers as table1. I tried running this insert
> statement:
>
> insert into table2(id) values(select id from table1
> where id not in (select id from table2))
>
> but get the error:
> ****************************************************
> insert into table2(id) values(select id from table1
> *
> ERROR at line 1:
> ORA-00936: missing expression
> ****************************************************
>
> Is it possible to use a subquery to insert several values?
>
> Thanks
> D.
>

Dump the 'values(...)' when selecting for insert.

insert into table2(id) select...

-- 
/Karsten
Received on Thu Feb 06 2003 - 18:38:03 CST

Original text of this message

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