MySQL Delete On Joined Tables
If you want to (for example) delete all users with the guest role from your database :
DELETE FROM user WHERE EXISTS (
SELECT * FROM role
WHERE role.id = user.role_id
AND role.name = 'guest'
);
If you want to (for example) delete all users with the guest role from your database :
DELETE FROM user WHERE EXISTS (
SELECT * FROM role
WHERE role.id = user.role_id
AND role.name = 'guest'
);
If you enjoyed this post, please follow us on twitter or subscribe to our feed!