2

How to select an int datatype field(bonus) which is inserted as NULL?

Tried the following but prints nothing though there is a valid entry.

select e_name from employee, payroll where datepart(year,hire_date)=2005 and employee.e#=payroll.e# and bonus=null

also if i want to add another year say 2007 to be checked with 2005 using or, what is the query for that?

1 Answer 1

3

When testing for null, you must use this syntax:

... 
and bonus is null

FYI the syntax for testing if not null is bonus is not null.

All other comparisons (eg =, <, like, etc) will return false with a null value.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.