Mysql异常:Every derived table must have its own alias
程序员文章站
2024-02-10 17:43:16
...
Mysql错误:Every derived table must have its own alias mysql执行多表查询时报错: [SQL] SELECT * from (select e.account from employee eUNIONSELECT u.account from `user` uUNIONSELECT a.account from agent a)[Err] 1248 - Every derived table mus
Mysql错误:Every derived table must have its own aliasmysql执行多表查询时报错:
[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,问题就解决了。
上一篇: 绑定变量窥视是否开启和直方图关系
下一篇: 再探PHP session_PHP教程
推荐阅读
-
Mysql异常:Every derived table must have its own alias
-
Mysql异常:Every derived table must have its own alias
-
MySQL碰到“Every derived table must have its own alias”类似错误说明
-
mysql “ Every derived table must have its own alias”出现错误解决办法
-
mysql “ Every derived table must have its own alias”出现错误解决办法
-
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”类似错误说明