Connecting Tech Pros Worldwide Help | Site Map

Data not eisting in tables

  #1  
Old January 20th, 2009, 10:36 PM
Newbie
 
Join Date: Jan 2009
Posts: 1
I amm having one of those DBA brain locks. I have two tables lets say table_1 and Table_2. The Join column in both (indexed) is col_1 ( variable character 75 ).

what I need to do is produce a record of those records in Table_1 that are not in
Table_2

over simplified example Data

Table_1 Col_1 Table_2 Col_1

abcd abcd
wxyz egka
wxyz wxyz

the Query needs to return "egka"



  #2  
Old January 21st, 2009, 09:39 AM
sagark's Avatar
Newbie
 
Join Date: Jan 2009
Location: Pune, India
Posts: 11

re: Data not eisting in tables


You can use query something like this -

"Select Col_2 from Table_2 where Col_2 not in (Select Col_1 from Table_1)"
  #3  
Old January 22nd, 2009, 08:18 AM
ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,914

re: Data not eisting in tables


Be careful with NOT IN. Read this and this.

Happy Coding!

-- CK
Reply

Tags
exist, not in, sql