Mysql uses variables to batch modify data BEGIN declare I int; # query the table's number of columns declare column_name_temp varchar (100); # query the table's column name DECLARE column_un_change varchar (100 ); DECLARE table_temp_name varchar (100); declare description varchar (100); declare code varchar (100); set column_un_change = 'other _ INCOME '; set description = 'description '; set code = 'code'; www.2cto.com set table_temp_name = 'wy _ notebill_detail2 '; ###################### store the column names of a table to a temporary table ########## ######### drop table if EXISTS update_column; create temporary table update_column (a int not null AUTO_INCREMENT, primary key (a) TYPE = MyISAM SELECT column_name from information_schema. 'columns 'where table_name = table_temp_name and column_name not in (column_un_change, description, code) and data_type not in ('date', 'datetime '); ####################### count columns ############## ###### SELECT count (*) into I from update_column; SELECT I; www.2cto.com loop1: WHILE I> 2 DO ######################### assign a column name to a variable ##### ################# SELECT column_name into column_name_temp from update_column where a = I; SET I = I-1; ######################### update table data ########### ############## set @ sqls = concat ('update ', table_temp_name, 'set', column_name_temp, '= 0'); PREPARE stmt1 from @ sqls; EXECUTE stmt1; end while loop1; # SELECT * from wy_notebill_detail; END author Liu zongcai