21-Jan-2022
.
Admin
Hello Friends,
This article will give you example of how to check if field is null or empty with if statement in MySQL?. I explained simply about check if field is null or empty with if statement example in MySQL. This tutorial will give you simple Check If Field is NULL or Empt SQL query.
In this post, You'll learn use MySQL check if column is null or empty in if statement. i will show you use of MySQL check if column is null or empty in case statement.
Here i will give you many example for MySQL check when null in if and empty field.
So let's see bellow solution:
Table: users_payment
So, let's see bellow solution:
Solution 1:
SELECT
id,
user_id,
charge,
IF(status IS NULL or status = '', 'PENDING', status) as status
FROM `user_payments`
Solution 2:
SELECT
id,
user_id,
charge,
CASE WHEN status IS NULL or status = ''
THEN 'PENDING'
ELSE status
END as status
FROM `user_payments`
Output:
It will help you...
#MySQL