1

When trying to select everything except when question_type!= 'A'; The row do not return data when question_type is NULL.

select * from table where question_type!= 'A';
1
  • Add in where OR question_type IS NULL Commented Jun 23, 2016 at 8:20

2 Answers 2

4

So, include that in the where clause;

select t.*
from table t
where question_type <> 'A' or question_type is null;

Or, use the "null-safe" equal:

select t.*
from table t
where not question_type <=> 'A' ;

ANSI SQL implements IS DISTINCT FROM and IS NOT DISTINCT FROM. The <=> operator is equivalent to IS NOT DISTINCT FROM.

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

1 Comment

The null-safe equal rocks!
1

Return a value in case of null and go ahead:

select * from table where COALESCE(question_type, '') <> 'A';

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.