Every derived table must has its own alias
It means that each derived table must have an alias of its own.
This error typically occurs when querying multiple tables.
Because the result of the subquery when the query is nested is a derived table for the previous level of the query, so 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 it only adds an alias total without any effect, but this alias is required
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 result is 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)
MySQL encounters "every derived table must with its own alias" similar to error description