Hello friends
I am having 3 tables as employee table, department table and employeedepartment tables
in the employee table I have empid and empName and in the department table I have depid and departmentName and in the empdepartment table I store empid and deptid.
Now in the emp table the value sare
1 A 2 B 3 C In the department table the values are
1 X 2 Y 3 Z
In the employee department table I have values dep id, empid 1 2 1 2
Now, I have to list the names of employees whose department is not allocated yet.
The values are A & C it is obvious and I have written the query as follows which gives me result
select distinct empname from emp,dept,empdept where dept.depid <> empdept.depid and emp.empid <> empdept.empid;
But, can any one suggest me a better query?
Please help me
My advance thanks
|
| Author: pradipta 20 Aug 2008 | Member Level: Gold | Rating:  Points: 2 |
You can try the following query
select empname from emp where empid in (select empid from empdept)
|
| Author: pradipta 20 Aug 2008 | Member Level: Gold | Rating:  Points: 2 |
Sorry Please ignore my presvious reply.the query shoiuld be
select empname from emp where empid not in (select empid from empdept)
|
| Author: Sankararaman 20 Aug 2008 | Member Level: Silver | Rating:  Points: 1 |
Hello Friends
I want this query without USING NOT IN. Please help me
My Advance thanks
|
| Author: Ramdas Singh Baghel 21 Aug 2008 | Member Level: Gold | Rating:  Points: 0 |
Your are sick man.
|