views:

16

answers:

2

Hello,

I have 2 tables: User (id, user, pass, ...)

Post (user_id, post, ...)

I would like to create a trigger wich delete post of a user, before deleting user... Can you help me?

A: 

Use a stored procedure

polemon
A: 

if the tables is innodb engine

you can use

ON DELETE CASCADE 

http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html

look an example here :

http://stackoverflow.com/questions/2914936/mysql-foreign-key-constraints-cascade-delete

Haim Evgi