mysql的dual表

mysql文档中对于dual表的解释:

You are allowed to specify DUAL as a dummy table name in situations where no tables are referenced:

mysql> SELECT 1 + 1 FROM DUAL;
-> 2

DUAL is purely for the convenience of people who require that all SELECT statements should have FROM and possibly other clauses. MySQL may ignore the clauses. MySQL does not require FROM DUAL if no tables are referenced.


目标:往数据库中插件不存在的记录,如果存在则不进行操作

INSERT INTO t SELECT 10 FROM DUAL where not exists(SELECT * FROM t WHERE id = 10);