0

In mysql table real_account_id's data type is int(11). I want to fetch all records with NULL values.

I am using this simple query.

SELECT * FROM `customer_payment_options` WHERE real_account_id = NULL

But, it's not giving me any results. There are 2 records in database with NULL value. I also tried with,

SELECT * FROM `customer_payment_options` WHERE real_account_id = 'NULL'

Why is it like this? Thanks.

0

1 Answer 1

7

NULL is equal to nothing including NULL. That's why you must use IS NULL:

SELECT * FROM `customer_payment_options` WHERE real_account_id IS NULL
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. Is there any technical reason behind that? Because, comparing with NULL is the same thing
To tell you the truth I am not sure why this is. A maybe good explanation can be found here.

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.