最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

mysql“Everyderivedtablemusthaveitsownalias”出现错误解决办法

来源:动视网 责编:小采 时间:2020-11-09 20:40:16
文档

mysql“Everyderivedtablemusthaveitsownalias”出现错误解决办法

mysqlEveryderivedtablemusthaveitsownalias出现错误解决办法:mysql Every derived table must have its own alias错误解决办法 Every derived table must have its own alias 这句话的意思是说每个派生出来的表都必须有一个自己的别名 一般在多表查询时,会出现此错误。 因为,进行嵌套查询的时候子查询出来的的结
推荐度:
导读mysqlEveryderivedtablemusthaveitsownalias出现错误解决办法: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错误解决办法

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)


感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

您可能感兴趣的文章:

  • mysql中错误:1093-You can’t specify target table for update in FROM clause的解决方法
  • 读取mysql一个库下面的所有的表table
  • MySQL无法重启报错Warning: World-writable config file ‘/etc/my.cnf’ is ignored的解决方法
  • mysql Event Scheduler: Failed to open table mysql.event
  • mysql中You can’t specify target table for update in FROM clause错误解决方法
  • 出现错误mysql Table ''performance_schema...解决办法
  • 文档

    mysql“Everyderivedtablemusthaveitsownalias”出现错误解决办法

    mysqlEveryderivedtablemusthaveitsownalias出现错误解决办法:mysql Every derived table must have its own alias错误解决办法 Every derived table must have its own alias 这句话的意思是说每个派生出来的表都必须有一个自己的别名 一般在多表查询时,会出现此错误。 因为,进行嵌套查询的时候子查询出来的的结
    推荐度:
    标签: 处理 错误 解决
    • 热门焦点

    最新推荐

    猜你喜欢

    热门推荐

    专题
    Top