• NULL and NOT IN (Oracle)

    Posted on March 26th, 2008 biexplorer No comments

    Here is a very interesting scenario.

    I have an employee table called EMP.

    1

    And I have a DEPT table.

    2

    Now, I write a query to find out all the employees who are part of any department. (DEPT_ID is properly updated and found in DEPT table)

    3

    Now, I want to know if any employee is not part of any department.

    4

    What??? No results? I know that employee with EMP_ID 9 doesn’t belong to any department. Where did he go?

    Is Oracle drunk? Is it giving me wrong results? Wait let me check with another query.

    Read the rest of this entry »