select * from (select CONCAT(code_str,'_day_tb') from main_list_table where code_str) as tb;
环境:ubuntu mysql 5.xx
目的:是想把从main_list_table 表中查询code_str结果,拼接上“_day_tb”做为一张表,并查询拼接后的表的数据。
结果:只返回拼接的表名,无法得到目标结果。 请大家帮忙!
...全文
68812打赏收藏
select结果做为表名select
select * from (select CONCAT(code_str,'_day_tb') from main_list_table where code_str) as tb; 环境:ubuntu mysql 5.xx 目的:是想把从main_list_table 表中查询code_str结果,拼接上“_day_tb”做为一张表,并查询拼接后的表的数据。 结果:只返回拼接的表名,无法得到目标结果。 请大家帮忙!
单条可以直接做,多条得存储过程里面写游村
select CONCAT(‘sellect * from ', code_str,'_day_tb') into @sql from main_list_table where code_str limit 1;
prepare st from @sql;
execute st;
deallocate prepare st;