Minus query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • doll
    New Member
    • Jul 2007
    • 24

    Minus query

    hi all
    I'm using two tables called t1,t2..i need to display the id's that are there in the 1st table but not in the second table..i hope the minus function will give the results..the query i wrote is

    select t1.id from t1
    minus
    select t2.id from t2

    is this query correct...its not working..please help

    thank you
  • azimmer
    Recognized Expert New Member
    • Jul 2007
    • 200

    #2
    Originally posted by doll
    hi all
    I'm using two tables called t1,t2..i need to display the id's that are there in the 1st table but not in the second table..i hope the minus function will give the results..the query i wrote is

    select t1.id from t1
    minus
    select t2.id from t2

    is this query correct...its not working..please help

    thank you
    It works like this:
    Code:
    SELECT t1.id
    FROM t1
    WHERE t1.id not in (SELECT t2.id FROM t2)

    Comment

    Working...