15.06.2015, 13:41
If relations are properly set up then what you experience should be impossible. If you did not use cascade or set null then the MySQL server will not allow you to delete a user if they still have one or more achievements.
To find orphaned records you might try something like:
Untested.
To find orphaned records you might try something like:
PHP код:
SELECT * FROM (
SELECT achievements.userid as a_uid, users.userid as u_uid FROM achievements LEFT JOIN users ON achievements.userid = users.userid) as temp
WHERE u_uid IS NULL