Results 1 to 3 of 3

Thread: SQL Server opposite of join?

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2001
    Location
    Los Angeles, CA
    Posts
    12

    Unhappy SQL Server opposite of join?

    What is the opposite of join in sql server 7 and how do I use it? I have two tables and I want to pull the records that are in one table but not in the other. I know in paradox its count = 0 but i cant figure it out for sql.

  2. #2
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    You can do something like this:

    Code:
    select * from t1 where t1.keyfield not in  (select t2.keyfield from t2)
    "It's cold gin time again ..."

    Check out my website here.

  3. #3
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Leavenworth KS USA
    Posts
    482
    You could also use:
    Code:
    SELECT tableA.fieldname 
    FROM tableA 
    LEFT OUTER JOIN tableB 
      ON tableA.fieldname = tableB.fieldname 
    WHERE tableB.fieldname is null
    Assuming your comparison fields are indexed, this is kinder to your server than using an IN clause on larger tables. Hope it helps.
    Last edited by Mongo; Jul 13th, 2001 at 06:04 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width