Not getting desired records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anurag275125
    New Member
    • Aug 2009
    • 79

    #1

    Not getting desired records

    Hello..

    I'm facing problem with a simple select query.
    this my table structure.

    Name Null? Type
    USER_ID NOT NULL VARCHAR2(10)
    USER_NAME NOT NULL VARCHAR2(30)
    PASSWORD VARCHAR2(30)

    I insert user_id, user_name but I left the password empty. Now when I run the following query:

    select * from hrms_user_login where user_id='123' and user_name='anur ag' and password='';

    It's giving no output.
    how can I get the output of this select query??

    thanks
  • magicwand
    New Member
    • Mar 2010
    • 41

    #2
    One of the oldies but goodies in each ANSI committee meeting since the 90's is the battle over the defiition, how empty strings should be treated.

    Whatever one might prefer:
    Oracle treats empty strings as NULL values.

    And comparing anything to to NULL with the <, >, =, and != operators results in FALSE (even NULL = NULL).

    You have to use the IS and IS NOT operators when you work with NULL values in oracle.

    So, you will get your data, when you execute:

    select * from hrms_user_login where user_id='123' and user_name='anur ag' and password is null;

    Comment

    Working...