我喜欢在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'
ERROR 1137 (HY000): Can't reopen table: 'temp_table'
您不能在同一查询中多次引用TEMPORARY表。
请阅读以下链接 http://dev.mysql.com/doc/refman/5.5/en/temporary-table- problems.html