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
);
为啥不报错啊?

浙公网安备 33010602011771号