strange behavior of <> to filter null values
Posted
by
Kerezo
on Stack Overflow
See other posts from Stack Overflow
or by Kerezo
Published on 2012-04-07T05:27:34Z
Indexed on
2012/04/07
5:28 UTC
Read the original article
Hit count: 110
Hi experts: I have a table Called tblAlarm
and it has some records like this:
I have another table for determine what user see what message:
Now I want to write a query to show Messages that user has not seen if message didinot expired.(for example it's year between BeginYear and EndYear and so on ...). I write this query:
SELECT *
FROM
tblAlarms LEFT OUTER JOIN tblUsersAlarms tua ON tblAlarms.Id=tua.MessageID
WHERE @CurrentYear BETWEEN tblAlarms.BeginYear AND tblAlarms.EndYear
AND @CurrentMonth BETWEEN tblAlarms.BeginMonth AND tblAlarms.EndMonth
AND @CurrentDay BETWEEN tblAlarms.BeginDay AND tblAlarms.EndDay
AND (@CurrentHour * 60 + @CurrentMinute) BETWEEN tblAlarms.BeginHour*60 + tblAlarms.BeginMinute AND tblAlarms.EndHour*60 + tblAlarms.EndMinute
--AND (tua.UserID <> 128 AND tua.UserID IS NULL)
and it returns :
but if I unComment last line it does not return any record.How I can determine what messages that users has not been seen?
thanks
© Stack Overflow or respective owner