我喜欢在失败的 MySQL 中连接一个临时表,这个想法很简单:
CREATE TEMPORARY TABLE temp_table LIKE any_other_table; -- srsly it does not matter which table
(
SELECT p1,p2,p3 FROM temp_table WHERE p4 = 1
) UNION (
SELECT p1,p2,p3 FROM temp_table WHERE p4 = 2
)
非常感谢任何帮助。
编辑:mysql 抛出的错误是 ERROR 1137 (HY000): Can't reopen table: 'temp_table'
最佳答案
您不能在同一查询中多次引用 TEMPORARY 表。
请阅读以下链接 http://dev.mysql.com/doc/refman/5.5/en/temporary-table-problems.html
关于mysql - MySQL中加入同表临时表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18831014/