如何从表名称为变量的MySQL中选择 [英] How to select from MySQL where Table name is Variable

查看:115
本文介绍了如何从表名称为变量的MySQL中选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在某些情况下,获取表名应该是从诸如以下的设置变量中获取的:

I have a case where getting the table name should be from a set variable like:

SET @ID_1 = (SELECT ID FROM `slider` LIMIT 0,1);
SET @Cat = (SELECT Category FROM `slider` LIMIT 0,1);
select * from @Cat where ID = @ID_1

但是这样做,MySQL会输出一个错误,所以有人可以告诉我我该如何实现,因为这是我在MySQL中的基本步骤.

but doing that way MySQL outputs an error, so could someone show me how I can achieve that, because these are my baby steps in MySQL.

推荐答案

您必须使用 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆