I have multiple tables holding infos about users and content.
Table users:
id name
5 foo
33 abc
Table imgs:
id uid img_name
1 5 bar
8 33 xy
Table user_permissions:
id uid permission_id
1 5 3
2 3 3
Table liked_content:
id contente_id content_holder_id likedby_id
1 8 33 5
2 1 5 56
If a user is deleted I want to delete all rows in all tables related to his user-id. This works fine if I add only one column per table.
DELETE users,
imgs,
user-permissions,
liked_content
FROM users,
imgs,
user-permissions,
liked_content
WHERE imgs.uid = users.id AND
user_permissions.uid = users.id AND
liked_content.content_holder_id = users.id AND
users.id = 5
Adding a second row in the WHERE-clause (likedby_id/liked_content-table) where the id can be found will not work.
...
WHERE imgs.uid = users.id AND
user_permissions.uid = users.id AND
liked_content.content_holder_id = users.id AND
liked_content.likedby_id = users.id AND
users.id = 5
What would be the correct way adding a second column to the query for a table already listed?