临时 Table 不存在错误
Tempory Table doesn't exist error
我使用 node js express
在 mysql 中创建了一个临时 table
var table_name = "table"+(+new Date());
var query = "create temporary table "+table_name+" "+select_query
当我 运行 这段代码在控制台中得到结果时
result of creating temp table OkPacket {
fieldCount: 0,
affectedRows: 1640,
insertId: 0,
serverStatus: 34,
warningCount: 0,
message: ')Records: 1640 Duplicates: 0 Warnings: 0',
protocol41: true,
changedRows: 0 }
但是当我尝试 select 来自这个 table 的数据时 mysql 给出了 table 不存在的错误。
我无法弄清楚此错误背后的原因。
请帮助找到这个问题的解决方案。
谢谢。
找了半天终于找到答案了
临时表仅在连接期间存在。如果您使用一个查询创建它,然后在新连接上执行单独的查询,它已经消失了。
我使用 node js express
在 mysql 中创建了一个临时 tablevar table_name = "table"+(+new Date());
var query = "create temporary table "+table_name+" "+select_query
当我 运行 这段代码在控制台中得到结果时
result of creating temp table OkPacket {
fieldCount: 0,
affectedRows: 1640,
insertId: 0,
serverStatus: 34,
warningCount: 0,
message: ')Records: 1640 Duplicates: 0 Warnings: 0',
protocol41: true,
changedRows: 0 }
但是当我尝试 select 来自这个 table 的数据时 mysql 给出了 table 不存在的错误。
我无法弄清楚此错误背后的原因。
请帮助找到这个问题的解决方案。
谢谢。
找了半天终于找到答案了
临时表仅在连接期间存在。如果您使用一个查询创建它,然后在新连接上执行单独的查询,它已经消失了。