今天看到有人用DUAL表。了解了一下。 官方文档就解释的很好了:
You are permitted to specify DUAL as a dummy table name in situations where no tables are referenced:
不知道涉及哪个表的时候,可以指定DUAL作为一个假的表名:
mysql> SELECT 1 + 1 FROM DUAL;
-> 2
DUALis purely for the convenience of people who require that allSELECTstatements should haveFROMand possibly other clauses. MySQL may ignore the clauses. MySQL does not requireFROM DUALif no tables are referenced.
DUAL单纯为了方便声明了SELECT,需要使用FROM或者其他子句的时候。MySQL可能忽略这些子句。如果没有指定表,MySQL不需要FROM DUAL。