Connecting Tech Pros Worldwide Forums | Help | Site Map

Data not eisting in tables

Newbie
 
Join Date: Jan 2009
Posts: 1
#1   Jan 20 '09
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"



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

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)"
ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#3   Jan 22 '09

re: Data not eisting in tables


Be careful with NOT IN. Read this and this.

Happy Coding!

-- CK
Reply

Tags
exist, not in, sql