Solved

Need to select for missing referencial integrity

Posted on 2010-09-14
1
317 Views
Last Modified: 2012-05-10
I've noticed some records where I have zero for the id of a foreign key.

I'd like a query which will tell me which records don't reference my main table.

My main table is called Pads, the primary key is PadID, the field with zero entries is AuthorID
My Other table is Authors and the primary key is AuthorID.

So I want a list of Author Records where the AuthorID doesn't appear in the pads table.
0
Comment
Question by:mindwarpltd
1 Comment
 
LVL 31

Accepted Solution

by:
RiteshShah earned 500 total points
ID: 33671465
select * from Authors where AuthorID not in (Select distinct AuthorID from Pads)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now