Suppose there are two tables created:
CREATE TABLE emp
(
EMPNO int,
EMPNAME varchar(255),
JOB varchar(255),
DEPTNO int
);
CREATE TABLE dept
(
LOC varchar(255),
DEPTNO int
);
I want to know which department has no job. I am using a left join as follows:
select dept.*
from dept
left join emp
on (dept.deptno=emp.deptno)
where emp.empno is null;
But if I use an alias for dept or emp, then I can only use an alias and cannot use the name of the source table. For instance:
select dept.*
from dept as d
left join emp
on (dept.deptno=emp.deptno)
where emp.empno is null;
I get the error "there is no such table: dept" from sqlite.
If I run operations on the same table, I can use the alias and name of the source table in the same query.
Does anyone know why?
source
share