如何使用存储的函数而不是显式编写的表名。 我的问题:
select "col_name" from get_table("col_name") where id = 2;
get_table(col_name)
是我的存储函数,它在处理列名后返回表名。
我收到错误消息
错误代码:1064。您的SQL语法有错误;查看与您的MySQL服务器版本相对应的手册,以便在'(" col_name")附近使用正确的语法,其中id = 2'在第1行
我也尝试这样做:
DECLARE tableName varchar(30);
set tableName = get_table("col_name");
...
select "col_name" from tableName where id = 2;
这次我收到错误:
没有这样的表 - tableName