如何在 MARIADB/MYSQL 中为函数/过程声明表变量?

2022-01-15 00:00:00 function database mariadb mysql procedure

不知道如何操作MySQL DECLARE THIS TABLE?

I don't know how to operate MySQL DECLARE THIS TABLE?

MS_SQL CAN 
DECLARE @TEMP TABLE 
(variable INT)  

但是 MySQL 不能这样做!我该怎么做?

But MySQL can't do this! How can i do it?

语法错误!!

推荐答案

如果您需要使表或数据库名称来自参数或变量,则需要

If you need to make a table or database name come from an argument or variable, you will need to

  1. 构造查询,可能使用 CONCAT.
  2. PREPARE查询.
  3. 执行查询.
  4. DEALLOCATE PREPARE.
  1. Construct the query, probably using CONCAT.
  2. PREPARE the query.
  3. EXECUTE the query.
  4. DEALLOCATE PREPARE.

相关文章