Wrote this MySQL query to show all employees that aren't managers:
SELECT empno
FROM emp
WHERE empno NOT IN (SELECT mgr FROM emp);
but it shows no results. What could be the problem? This is the table.
CREATE TABLE emp (
empno int NOT NULL default 0000,
ename char(10) default NULL,
job char(9) default NULL,
mgr int default NULL,
hiredate datetime default NULL,
sal double default NULL,
comm double default NULL,
deptno int default NULL,
PRIMARY KEY (empno)
);
CodePudding user response:
SELECT empno
FROM emp
WHERE empno NOT IN (SELECT mgr FROM emp WHERE mgr IS NOT NULL) ;