欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

MySQL 脚本报错:Every derived table must have its own alias 每个派生表必须有自己的别名

程序员文章站 2022-09-05 13:10:32
Every derived table must have its own alias原因程序在连接mysql数据库时,查询报错,问题原因是mysql每个派生表必须有自己的别名,当执行下面这条sql语句的时候就会出现Every derived table must have its own aliasselect count(1) from (select * from A a inner join B b on a.bid = b.id) 解决如下所示,应该在最外层查询结果后面加一个...

Every derived table must have its own alias

原因

程序在连接mysql数据库时,查询报错,问题原因是mysql每个派生表必须有自己的别名,当执行下面这条sql语句的时候就会出现Every derived table must have its own alias

select count(1) from (
	select * from A a
	 inner join B b on a.bid = b.id
) 

解决

如下所示,应该在最外层查询结果后面加一个别名.

select count(1) from (
select * from A a
inner join B b on a.bid = b.id
) temp

问题解决


天下英雄出我辈,一入江湖岁月催
我是「无间行者」,努力把实践过的解决方案分享给大家
如果这篇文章对你有用,一个赞、一个评论、一个关注,我都很开心
码字不易,给点鼓励吧,让我知道你在看

本文地址:https://blog.csdn.net/qq_35606010/article/details/107856782