Solved

Need to select for missing referencial integrity

Posted on 2010-09-14
1
318 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Trigger usage 2 59
mcrypt_create_iv() is deprecated 4 76
SQL Error in WHERE Clause 5 42
RDBMS and No sql database 4 47
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
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…

863 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

28 Experts available now in Live!

Get 1:1 Help Now