locked
sql query for MS access Db RRS feed

  • Question

  • User447704385 posted

    I am tryin to get records where certain fields are empty, but the following sql does not give me correct result. Please suggest corrections.

    Thanks for your help.


    SELECT [specimen Type], [Year], [Lab Number]
    From [PET Fish] where


    ltrim(rtrim([Diagnosis])) = '' or
    ltrim(rtrim([Results])) = '' or
    ltrim(rtrim([Sign out Date])) = ''


    It should return all records, but it returns none.


    Monday, June 7, 2010 1:15 PM

Answers

  • User1828997928 posted

    Are you certain the values are empty strings?  Is it possible they are null?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 7, 2010 2:19 PM

All replies

  • User1828997928 posted

    Are you certain the values are empty strings?  Is it possible they are null?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 7, 2010 2:19 PM
  • User826222609 posted

    You can use like this


    SELECT [specimen Type], [Year], [Lab Number]
    From [PET Fish] where


    ltrim( rtrim( ISNULL( [Diagnosis], '')) = '' or
    ltrim( rtrim( ISNULL( [Results], ''))) = '' or
    ltrim( rtrim( ISNULL( [Sign out Date], ''))) = ''

     

    Tuesday, June 8, 2010 12:51 AM