In SQL. (DB2)there is one Dept table and other Emp tableQuestion- select Emp Name from Emp whose Dept No. is not in Dept table and it is present in Emp table Plz tell the Query?

Showing Answers 1 - 9 of 9 Answers

Kiran Bondre

  • Jul 29th, 2006
 

This is the query when there is no parent-child relationship between tables.

select ename,emp.deptno from emp,dept
where dept.deptno!=emp.deptno;

  Was this answer useful?  Yes

Laxmi Prasad

  • Apr 2nd, 2007
 



select e.ename,e.deptno from emp as e,dept as d
where d.deptno=e.deptno and e.deptid not in select deptid from emp ;

  Was this answer useful?  Yes

M.Nagaselvam

  • Nov 4th, 2007
 

SELECT e.ename,e.deptno,d.deptno FROM emp e,dept dWHERE d.deptno=e.deptno AND e.deptid NOT IN(40,50,60) ;

  Was this answer useful?  Yes

zdmytriv

  • Jan 26th, 2008
 

SELECT Emp.Name FROM Emp WHERE ((SELECT COUNT(Dept.DeptNo) FROM Dept WHERE (Dept.DeptNo == Emp.DeptNo)) == 0)

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions