Every derived table must have its own alias
This statement means that each derived table must have an alias of its own
This error usually occurs when querying multiple tables.
Because the result of the subquery is used as a derived table for the higher level query when doing nested queries, the result of the subquery must have an alias
Change the MySQL statement to: select count(*) from (select * from ……) as total;
The problem is solved, although only an alias total is added which has no effect, but this alias is necessary
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;
The results are correct:
+———-+——+——+———–+——-+
| 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)
Similar Posts:
- How to Solve MYSQL Error: Every derived table must have its own alias
- MySQL error message: subquery returns more than 1 row and its solution
- Every derived table must have its own alias
- MYSQL Error: Invalid use of group function [How to Solve]
- sql Error: Every derived table must have its own alias [How to Solve]
- Oracle error: not a group by expression [How to Solve]
- Error: not a group by expression [How to Solve]
- You can’t specify target table for update….
- [Solved] MYSQL ERROR 1093 – You can’t specify target table ‘readbook’ for update in FROM clause
- With check option in SQL