sql - mysql, iterate through column names -
i of column names mysql table, loop through each column name , run stored procedure using column names variable. effect of:
colnames = column names table  each colname   if changed       else     else   it looks show columns mytable give me column names, how column names loop?
i run of in stored procedure using native sql. since i'm still learning intricacies of mysql, , out project. help.
i think want this:
declare col_names cursor   select column_name   information_schema.columns   table_name = 'tbl_name'   order ordinal_position;   select found_rows() num_rows;  set = 1; the_loop: loop     if > num_rows         close col_names;         leave the_loop;     end if;       fetch col_names      col_name;            //do whatever else need col name      set = + 1;   end loop the_loop;      
Comments
Post a Comment