Tuesday 15 September 2015

MySQL dynamic loop through table and delete rows based on condition -



MySQL dynamic loop through table and delete rows based on condition -

is possible loop through tables , delete rows based on status can tables this:

select table_name information_schema.tables table_schema = 'mytables'

is possible loop through them , perform query similar this:

delete table now() > columnname

loop through statement selects tables , every table_name execute:

begin set @s = concat('delete from',table_name,' now() > columnname'); prepare stmt @s; execute stmt; deallocate prepare stmt; end

mysql

No comments:

Post a Comment