3

I want to filter the records that COMMENTS attribute is null

enter image description here

I have tried

SELECT TABLE_NAME, COMMENTS FROM 
    (SELECT TABLE_NAME, COMMENTS FROM (select * FROM user_tab_comments))
    WHERE COMMENTS != null;

But it didn't return the right output. How can I do it?

1 Answer 1

9

NULL is a state not a value, therefore you can't use normal operators on it. Use IS NULL or IS NOT NULL instead.

SELECT TABLE_NAME, COMMENTS 
  FROM (SELECT TABLE_NAME, COMMENTS FROM (select * FROM user_tab_comments))
    WHERE COMMENTS IS NOT NULL;

Just saw that you don't need all those subqueries

SELECT TABLE_NAME, COMMENTS 
  FROM user_tab_comments 
 WHERE COMMENTS IS NOT NULL;
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.