Skip to content

All topics  /  MySQL

MySQL If Statement With IS NOT NULL Example

MySQL ·

Hello Friends,

This article will give you example of MySQL if statement with is not null. I explained simply about MySQL if statement with is not null in SQL query. This tutorial will give you example of MySQL if statement with is not null.

In this post, You'll learn use how to use if statement with is not null in MySQL. i will show you use of if statement with is not null in MySQL.

Here i will give you many example for MySQL if statement with is not null.

Table: user_payments


So, let's see bellow solution:

Solution SQL Query:

SELECT 
    id, 
    user_id, 
    CASE WHEN charge IS NOT NULL 
       THEN charge
       ELSE 0
    END as charge, 
    payment_date 
FROM `user_payments`

Output:

It will help you...