我正在学习存储过程。出现问题我有一个表,其中列被命名为Q1,Q2,Q3 ......,Q10。我想使用while循环(或for循环)动态检索这些值。我尝试了一些但没有给我实际输出的东西。请给我一些建议。
我的代码如下:
delimiter //
drop procedure if exists exam//
create procedure exam ()
begin
declare a int default 1;
while a <= 9 do
select concat(Q,a) from feed1 where col = 'XYZ';
set a= a + 1;
end while;
end ;
//
delimiter ;
call exam;
当我运行此操作时,我收到错误“字段列表中的未知列Q”