MySQL多表查询时起别名

select *
from(
    select emp_no,count(distinct salary) as t
    from salaries
    group by emp_no
)
where t>15

这个语法会报错,在第六行,报错的原因是这个子查询必须要起别名
SQL_ERROR_INFO: 'Every derived table must have its own alias'

select *
from(
    select emp_no,count(distinct salary) as t
    from salaries
    group by emp_no
)as t1
where t>15

但是

select e.emp_no
from employees e 
where e.emp_no not in (
    select emp_no from dept_manager
);

为啥不报错啊?

作者:Zhbeii

出处:https://www.cnblogs.com/zhbeii/p/16093296.html

版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。

posted @   Zhbeii  阅读(280)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
more_horiz
keyboard_arrow_up light_mode palette
选择主题
点击右上角即可分享
微信分享提示