Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7754927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:26:13+00:00 2026-06-01T12:26:13+00:00

Hi experts: I have a table Called tblAlarm and it has some records like

  • 0

Hi experts: I have a table Called tblAlarm and it has some records like this:

enter image description here

I have another table for determine what user see what message:

enter image description here

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 :

enter image description here

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:26:15+00:00Added an answer on June 1, 2026 at 12:26 pm

    The result of comparing a NULL with a value is UNKNOWN. A filter condition only selects rows where the conditions evaluate to TRUE, so rows where the condition evaluates to FALSE or UNKNOWN are not selected.

    The IS NULL and IS NOT NULL tests are different and always produce a TRUE or FALSE answer. You also cannot write column = NULL or column != NULL (at least, the SQL standard does not allow that; some SQL dialects may).

    Your condition is:

    AND (tua.UserID <> 128 AND tua.UserID IS NULL)
    
    • If the value of tua.UserID is NULL, then the second term evaluates to TRUE, but the first will then evaluate to UNKNOWN, and UNKNOWN and TRUE is UNKNOWN, which is not TRUE, so the row is not selected.

    • If the value of tua.UserID is not NULL, then the second term evaluates to FALSE, so the overall condition evaluates to FALSE, and so the row is not selected.

    Hence, when you add the condition, nothing is selected, as you observed.

    More typically, your condition would be either of these two:

    AND (tua.UserID <> 128 AND tua.UserID IS NOT NULL)
    
    AND (tua.UserID <> 128 OR tua.UserID IS NULL)
    

    The double condition in the first alternative is in fact redundant. If tua.UserID is NULL, the first term will evaluate to UNKNOWN, so the overall condition would not be TRUE and the row would not be selected. The second alternative is quite useful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to have a table like this: Manager Expert Adminis. Staff Dept
Right... calling all Entity Framework experts... I have a table called Bob in my
I have a database table that has a structure like the one shown below:
I have a mysql table , which holds data like this. Name |how_out |runs
Hi Experts: I have a class which extends JPanel now ShapePanel (Sp) this gets
This is a simple htaccess question for experts but I have been trying to
Experts - I need some advice in the following scenario. I have a configuration
Greetings, I have a table that looks like the following: date value 2007-11-05 134
Suppose each Person has a collection of favorite Books. So I have a table
I have a database table called ' members '. Assigned to members is a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.