MySQL Forums
Forum List  »  Newbie

Finding broken links
Posted by: Jos Elkink
Date: May 09, 2005 09:30AM

When I use foreign keys in a table and I want to check which ones are referring to entries that do not exist anymore, how could I do this?

E.g. if chars.location refers to locations.id, I can do something like:

SELECT chars.id,chars.name,locations.name FROM chars,locations WHERE chars.id=locations.id;

And automatically all those where chars.location is referring to a non-existing locations.id are left out of the table. How do I get exactly the opposite subset, only those where locations.id indeed does not exist? (So I can repair these inconsistencies in my database.)

Thanks in advance for any help!

Options: ReplyQuote


Subject
Written By
Posted
Finding broken links
May 09, 2005 09:30AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.