dbTalk Databases Forums  

select from a list where not in a table

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss select from a list where not in a table in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
dmclaude
 
Posts: n/a

Default select from a list where not in a table - 12-13-2004 , 11:53 AM






All,

I am trying to select from a list of ids where the ids are not in a
table. So far all I've come up with is adding all the ids to a
temporary table and then selecting from one where not in the other.

Is there an easy (no table creation) way to do this?

eg. (in pseudo code)

Table Test
id varchar (2)
{'aa', 'cc', 'dd')

List testList
('aa', 'bb')

I want to be able to see 'bb' is in list testList but not in table
Test.

appreciate any help
-dmclaude


Reply With Quote
  #2  
Old   
Alan
 
Posts: n/a

Default Re: select from a list where not in a table - 12-13-2004 , 12:00 PM







"dmclaude" <dmclaude (AT) yahoo (DOT) com> wrote

Quote:
All,

I am trying to select from a list of ids where the ids are not in a
table. So far all I've come up with is adding all the ids to a
temporary table and then selecting from one where not in the other.

Is there an easy (no table creation) way to do this?

eg. (in pseudo code)

Table Test
id varchar (2)
{'aa', 'cc', 'dd')

List testList
('aa', 'bb')

I want to be able to see 'bb' is in list testList but not in table
Test.

appreciate any help
-dmclaude

Look up WHERE...IN




Reply With Quote
  #3  
Old   
Bricklen
 
Posts: n/a

Default Re: select from a list where not in a table - 12-13-2004 , 12:10 PM



dmclaude wrote:
Quote:
All,

I am trying to select from a list of ids where the ids are not in a
table. So far all I've come up with is adding all the ids to a
temporary table and then selecting from one where not in the other.

Is there an easy (no table creation) way to do this?

eg. (in pseudo code)

Table Test
id varchar (2)
{'aa', 'cc', 'dd')

List testList
('aa', 'bb')

I want to be able to see 'bb' is in list testList but not in table
Test.

appreciate any help
-dmclaude

go to asktom.oracle.com and look for "variable in list"


Reply With Quote
  #4  
Old   
Mark C. Stock
 
Posts: n/a

Default Re: select from a list where not in a table - 12-13-2004 , 06:59 PM




"dmclaude" <dmclaude (AT) yahoo (DOT) com> wrote

Quote:
All,

I am trying to select from a list of ids where the ids are not in a
table. So far all I've come up with is adding all the ids to a
temporary table and then selecting from one where not in the other.

Is there an easy (no table creation) way to do this?

eg. (in pseudo code)

Table Test
id varchar (2)
{'aa', 'cc', 'dd')

List testList
('aa', 'bb')

I want to be able to see 'bb' is in list testList but not in table
Test.

appreciate any help
-dmclaude

you've answered your own question :

Quote:
I am trying to select from a list of ids where the ids are --->>not
in<<---

you'll see that you've described your problem with the operator that you
need to use

also, temporary tables are infrequently used in solving problems -- they are
somewhat of a last resort. usually there is an efficient and relatively
straight-forward way to solve the problem using SQL syntax, often using a
subquery (another hint for your situation)

++ mcs




Reply With Quote
  #5  
Old   
Sujit
 
Posts: n/a

Default Re: select from a list where not in a table - 12-14-2004 , 03:01 AM



I think a PL /Sql table should help u to store the records .... if you
want to make the data in it to be persistant you could always declare
it in a package !!!

Then doin a not in should solve ur problem. But i think a join would be
a better option
cause a not in will do a full table scan.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.