Every derived table must have its own alias
这句话的意思是说每个派生出来的表都必须有一个自己的别名
一般在多表查询时,会出现此错误。
因为,进行嵌套查询的时候子查询出来的的结果是作为一个派生表来进行上一级的查询的,所以子查询的结果必须要有一个别名
把MySQL语句改成:select count(*) from (select * from ……) as total;
问题就解决了,虽然只加了一个没有任何作用的别名total,但这个别名是必须的
select name1 name, java, jdbc, hibernate,total
from (select sc1.name name1, sc1.mark java
from student_course2 sc1
where sc1.course='java') as a,
(select sc2.name name2, sc2.mark jdbc
from student_course2 sc2
where sc2.course='jdbc') as b,
(select sc3.name name3, sc3.mark hibernate
from student_course2 sc3
where sc3.course='hibernate') as c,
(select sc4.name name4,sum(sc4.mark) total
from student_course2 sc4 group by sc4.name) as d
where name1=name2 and name2=name3 and name3=name4 order by total ASC;
结果正确:
+----------+------+------+-----------+-------+
| name | java | jdbc | hibernate | total |
+----------+------+------+-----------+-------+
| wangwu | 40 | 30 | 20 | 90 |
| lisi | 70 | 60 | 50 | 180 |
| zhangsan | 100 | 90 | 80 | 270 |
+----------+------+------+-----------+-------+
3 rows in set (0.02 sec)
相关推荐
NULL 博文链接:https://happyfling.iteye.com/blog/2313240
mysql Every derived table must have its own alias错误解决办法 Every derived table must have its own alias 这句话的意思是说每个派生出来的表都必须有一个自己的别名 一般在多表查询时,会出现此错误。 ...
主要介绍了Mysql错误Every derived table must have its own alias解决方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
本文实例讲述了mysql派生表(Derived Table)简单用法。分享给大家供大家参考,具体如下: 关于这个派生表啊,我们首先得知道,派生表是从select语句返回的虚拟表。派生表类似于临时表,但是在SELECT语句中使用派生...
(b) the name of the table, the names of the table's attributes, the data types of the table's attributes, the formats of the table's attributes, and the maximum number of rows that the table can have ...
experienced with MySQL and, ideally, have read an introductory book on it. We also assume some experience with general system administration, networking, and Unix-like operating systems. This revised ...
Many of them were derived from think- ing about that mythical perfect MySQL book that none of us had read but that we kept looking for on bookstore shelves. Others came from a lot of experience ...
Design two classes circle and table, and then based on the two classes define a new derived class roundtable by multi-inherit. The output of the program should include the height of the table, the ...
使用EXPLAIN关键字可以模拟优化器执行SQL查询语句,从而知道MySQL是如何处理你的SQL语句的。分析你的查询语句或是表结构的性能瓶颈。 如下面SQL语句: EXPLAIN select * from system_area where status = 1 获得...
Zero-Difference Balanced Function Derived from Fermat Quotients and Its Applications
derivedclass.layout
** * Redistributions of source code must retain the above ...** of its contributors may be used to endorse or promote products derived ** from this software without specific prior written permission.
一个从Liu系统衍生的四维分数阶超混沌系统及其电路研究,韩强,孙蕾,本文提出了一个从Liu系统衍生出来的新的四维超混沌系统。EWB和Matlab对其进行的数值仿真展示了该四维超混沌系统的动力学行为。...
Objective Image Quality Measure Derived from Digital Image Power Spectra,1922 很经典的论文,关于图像质量评价体系的鼻祖之作。
* Neither the name of Kontrollsoft nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS...
【大厂面试题】MySQL执行计划及SQL优化 知识点标签:explain、sql优化、索引、sql性能问题 题目描述 ...DERIVED:在from列表中包含的子查询被标记为derived(衍生),mysql或递归执行这些子 查询,把结果
theory, with its own basic notions, fundamental results and deep open prob- lems, andwith significantapplicationstoothermathematical theories. At the sametime,...
某绿色三角校徽,大二下,c++,课后作业。没差的话一积分搞下来,错了找我!欢迎私聊。其他作业可以看我的上传资源。收积分单纯为了替大伙查看高分资源再低价转出,请多多支持!