Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQL Query

 
Nair Anoop
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi !
I have 2 tables with the following structure:
Table 1: A | B | C
---------
rec.1 a1| b1| c1
rec.2 a1| b2| c1
and
Table 2: B | C | D
-----------
b1| c1| d1
b2| c2| d2
Could someone help me with a query which finds all records from Table 2 with the pair (b,c) which are NOT present in Table 1.
(In above eg. it should return (b2, c2, d2) since the pair (b1, c1) is present in Table 1)
I'm sure its a simple query .. but can't seem to think of anything.
Thanks in advance,
Anoop


[This message has been edited by Nair Anoop (edited September 19, 2001).]
 
Daniel Dunleavy
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do an outer join and part of the where is A is null
which would be all the records which did not have a match
This is assuming that null is not a valid value for column A
Dan
 
namita pa
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
to make it a bit more simpler for you try this query...............
select table2.b, table2.c, table2.d from table2, table1 where not (table2.b=table1.b or table2.c=table.c);
i hope this would work as per your requirement
all the best
namita

------------------
 
Nair Anoop
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Namita and Daniel for your help
~Anoop
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic