1. 程式人生 > >用concat批量生成MySQL查詢語句

用concat批量生成MySQL查詢語句

and mem local from rsh prop sql select lec

select concat(‘grant all on ‘, table_schema,".",table_name," to ‘ gxsnerp‘@‘localhost ‘;") from tables where table_schema=‘gxsnerp‘ and table_name like ‘ACT%‘;

生成拼接語句如下:
grant all on gxsnerp.ACT_HI_VARINST` to ‘gxsnerp‘@‘localhost‘;
grant all on gxsnerp.ACT_GE_PROPERTY to ‘gxsnerp‘@‘localhost‘;

grant all on gxsnerp.ACT_ID_MEMBERSHIP to ‘gxsnerp‘@‘localhost‘ ;
grant all on gxsnerp.ACT_HI_ACTINST to ‘gxsnerp‘@‘localhost‘ ;

用concat批量生成MySQL查詢語句