Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SQL:  TableA records not in TableB

Posted on 2006-04-18
3
Medium Priority
?
932 Views
Last Modified: 2006-11-18
(gotta love these late-afternoon brain cramps)

TableA, say 440 records, only field is ID
TableB, say 400 records, only field is ID

How to write SQL that returns the 40 TableA records that are not in TableB?  Something like...

SELECT ID
FROM TableA
LEFT JOIN TableB ON TableA.ID = TableB.ID
WHERE TableB.ID {is not in table A}

Thanks in advance.
-Jim
0
Comment
Question by:Jim Horn
  • 2
3 Comments
 
LVL 70

Accepted Solution

by:
Scott Pletcher earned 1000 total points
ID: 16482528
SELECT TableA.id
FROM TableA
LEFT OUTER JOIN TableB ON TableA.id = TableB.id
WHERE TableB.id IS NULL
0
 
LVL 70

Expert Comment

by:Scott Pletcher
ID: 16482531
SQL will automatically set every column in a not-found outer join table to NULL.
0
 
LVL 66

Author Comment

by:Jim Horn
ID: 16482602
ty
-Jim
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question