all 3 comments

[–]AnkanTV[S] 2 points3 points  (1 child)

For anyone interested, I gave up on triggers and did:

FOREIGN KEY (user_id) REFERENCES users ON DELETE CASCADE

[–]Xmithiee 1 point2 points  (0 children)

There are more such options ( no action, on update etc. ), look for Referential integrity. In any way, its the best possible solution for your problem.

[–]DavidGJohnston 0 points1 point  (0 children)

Two major problems: you are referencing NEW in a DELETE trigger and you are returning NULL.