I am trying to delete a post I have created, but that post could also have likes or comments.
So obviously I want to be able to delete those comments or likes if I try to delete the post!
Now I have some code which is kind of working.
This code:
DELETE p, a, n
FROM Posts p
INNER JOIN Activity a ON a.uuidPost = p.uuid
LEFT OUTER JOIN Notifications n ON n.uuidPost = p.uuid
WHERE p.uuid = '$uuid'
Deletes the post, but only if there is some activity(for ex. likes or comments), but if there are no likes or comments It does not delete the post...
I could do with some help trying to understand why this is happening if possible?!
Many thanks in advance to anyone that can spare some time for me!
INNER JOINonly finds rows if they match in both tables. That's the difference betweenINNER JOINandOUTER JOIN.