Deleting where a primary is not linked to a foreign key
Posted: 19 Feb 2010, 10:37
Hi all,
As the title says: I have a table with images (it has a primary key and an image column), and several other tables with foreign keys linked to this table.
Now as it happened, I uploaded images to this table more than once, while testing an app, so there are a lot of images in the table which aren't linked to any of the other tables' foreign keys. Basically redundant data.
How do I delete entries from this image table where the primary keys AREN'T linked to foreign keys in other tables?
I've searched around the net, but I can't find anything.
As the title says: I have a table with images (it has a primary key and an image column), and several other tables with foreign keys linked to this table.
Now as it happened, I uploaded images to this table more than once, while testing an app, so there are a lot of images in the table which aren't linked to any of the other tables' foreign keys. Basically redundant data.
How do I delete entries from this image table where the primary keys AREN'T linked to foreign keys in other tables?
I've searched around the net, but I can't find anything.