php - MySQL delete rows from other tables if deleted from main table -
I've added a custom table in a WordPress DB named wp_likeandfollow, it has 4 columns
id ==== following_ id ==== follower_ id ==== network_id here follower_id and the following_ id real < Code> ID and users can have duplicate entries. I would like to make an inquiry that if the administrator deletes a user from the admin panel, then all the entries of that user should also be deleted automatically in the likeandfollow table, and I want to do this with MySQL
You can use a trigger for this. Delete the trigger after removing it on wp_users for each line; Create likes_and_follows wp_likeandfollow WHERE wp_likeandfollow.following_id = old.id; END Where old.id will be in this case wp_users.id .
Comments
Post a Comment