Why is this not displaying null values?

  • I have a table and in that table there is a column org_name_1 which contains various values, one in particular i do not want to include on a report is 'legal specialties' then i add the line "and o.org_name_1 <>'legal specialties'" to my code, it ONLY displayes the records with a value in that field, and NOT null values. I need to display null values, and ALL other values besides "legal specialties" why is it getting rid of nulls?

  • sample data

    what is displayed:

    taco bell

    kfc

    mcdonalds

    what i would like displayed

    taco bell

    null

    null

    kfc

    ect....

    Basically if a person has Null data in this field, i would like that to be displayed even though i specified <>'legal specialties' Im not sure why when i take out legal specialties it removes null values as well?

  • There was recently an article on this site.

    Right for you.

    http://www.sqlservercentral.com/articles/Advanced+Querying/2829/

    _____________
    Code for TallyGenerator

  • I actaully read that as part of my research, but im not searching or comparing null values, i just want them to be displayed, what am i missing here?

  • Think i found it.

    "Most likely it's because in queries only rows for which the WHERE clause condition evaluates to TRUE are returned. Rows that evaluate to FALSE or UNKNOWN are not returned"

    So if i have org_name_1 <>'legal specialties' and there is a "null" value in that column you cant compare 'legal specialties' to "null" because it will come out unknown and not display.

    Am i right? 😀

  • Exactly.

    _____________
    Code for TallyGenerator

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply