Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2005
    Posts
    92

    Unanswered: Null in Date column

    Hi All,

    There is a column "update_date" of Date datatype. This is a nullable column. the "update_date" column is available in 2 tables table A and Table B.

    I am trying to fetch everything from Table A when tableA.update_date <> tableB.update_date.

    the update_date in table B is not populated (basically not data)

    select tableA.ID, tableB.address from table A, table B where tableA.update_date <> tableB.update_date do not work for me.

    no data is returned. but i can clearly see from the data in 2 tables that update_date do not match in both tables.

    can someone please suggest me.

    Table A
    ID state update_date
    1 il 2/17/2015
    2 MS 2/16/2015
    3 TX


    Table B
    ID Address update_date
    4 Harrison st
    5 king st
    6 queen st

    Thanks
    pavan

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    Remember the DATE datatype also contain a time component.
    I offer SQL below even though I think that above is a malformed problem statement.

    SELECT ID,STATE, UPDATE_DATE FROM TABLEA
    WHERE UPDATE_DATE NOT IN (SELECT UPDATE_DATE FROM TABLEB);
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Oct 2005
    Posts
    92

    Null in date column

    I actually ran this expecting output from the SQL, but no rows returned.

    select tableA.ID, tableB.address from table A, table B where trunc(tableA.update_date) <> trunc(tableB.update_date)

    i know from the data in the table A the tableA.update_date is populated however the update_date in table B is null (no data).

    Thanks
    Shiv

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >I actually ran this expecting output from the SQL,

    You should correct your expectations & improve your knowledge of SQL & NULL

    WHERE ANYTHING = NULL -- is always FALSE
    WHERE ANYTHING <> NULL -- is always FALSE

    WHERE ANYTHING IS NULL -- ???
    WHERE ANYTHING IS NOT NULL -- ???
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  5. #5
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    So, based on Table A and Table B data you posted in the first message, what output do you expect?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •