On 12.12.2010 01:27, John May wrote:
SELECT COUNT(*) FROM identities WHERE user_id NOT IN (SELECT user_id FROM users);
1
SELECT COUNT(*) FROM contacts WHERE user_id NOT IN (SELECT user_id FROM users);
56
So, you have some records that shouldn't be there. You can delete them with
DELETE FROM identities WHERE user_id NOT IN (SELECT user_id FROM users); DELETE FROM contacts WHERE user_id NOT IN (SELECT user_id FROM users);