Jump to content

wild card delete


EchoFool

Recommended Posts

Here's manual entry on table constraints:

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

 

They can be defined so that when you delete a row from 'parent' table (e.g. 'users') all rows in 'child' tables (for example 'messages') will be deleted automatically.

 

 

Anyway:

SELECT CONCAT(TABLE_SCHEMA,'.',TABLE_NAME) FROM `information_schema`.`COLUMNS` WHERE COLUMN_NAME = 'UserID';

 

will fetch you a list of all tables having 'UserID' column. Then you just need to run DELETE query on each of them. You should be able to do this in, say, 25 lines of PHP

Link to comment
https://forums.phpfreaks.com/topic/196642-wild-card-delete/#findComment-1032447
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.