Search code examples
sqlnullintersystems-cache

Comparing null values in Caché


I have this query:

SELECT  *
FROM    Ens.MessageHeader head ,EnsLib_HL7.Message as body
WHERE   head.MessageBodyId = body.ID
AND     body.Name IN ('ADT^A34','ADT^A40')
AND     MessageBodyClassName = 'EnsLib.HL7.Message'

Which gives results like this:

enter image description here

I want to only get the records where BusinessProcessId is null so I add this line:

AND     BusinessProcessId IS NULL

But now I get no results.

enter image description here

I've tried a few variants but nothing seems to do what I expect. What am I doing wrong?


Solution

  • Try this query:

    SELECT *
    FROM   Ens.MessageHeader head, EnsLib_HL7.Message as body
    WHERE  BusinessProcessId IS NULL
    

    if it yields any results, then recheck other query conditions.