MySQL encounters "every derived table must with its own alias" Similar error description

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.