Mysql错误Every derived table must have its own alias解决方法
程序员文章站
2022-03-06 09:47:56
mysql执行多表查询时报错:
[sql] select * from
(
select e.account from employee e
union...
mysql执行多表查询时报错:
[sql] select * from ( select e.account from employee e union select u.account from `user` u union select a.account from agent a ) [err] 1248 - every derived table must have its own alias
这句话的意思是每个派生出来的表必须有一个自己的别名
一般是在多表查询或者子查询的时候会出现这个错误,因为在嵌套查询中,子查询的结果是作为一个派生表给上一级进行查询,所以子查询的结果必须有一个别名。
上面的例子中,把查询语句修改一下:
select * from ( select e.account from employee e union select u.account from `user` u union select a.account from agent a )as total
如上所示,在子查询的后面增加一句 as total,相当于给子查询的结果集派生表取别名为total,问题就解决了。
推荐阅读
-
MySQL 脚本报错:Every derived table must have its own alias 每个派生表必须有自己的别名
-
Mysql错误Every derived table must have its own alias解决方法
-
mysql-MySQL错误Every derived table must have its own alias
-
mysql-MySQL错误Every derived table must have its own alias
-
MySQL碰到“Every derived table must have its own alias”类似错误说明
-
【mysql解决方案】ERROR 1248 (42000): Every derived table must have its own alias
-
mysql原生SQL查询错误出现异常“ Every derived table must have
-
mysql原生SQL查询错误出现异常“ Every derived table must have
-
MySQL 脚本报错:Every derived table must have its own alias 每个派生表必须有自己的别名
-
Mysql错误Every derived table must have its own alias解决方法