Loading

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
);

为啥不报错啊?

posted @ 2022-04-02 17:44  Zhbeii  阅读(292)  评论(0)    收藏  举报