Skip to content

All topics  /  MySQL

MySQL CASE WHEN Function Example

MySQL ·

Hello Friends,

This article will give you example of MySQL case when function example. I explained simply about MySQL case when then multiple statements. This tutorial will give you simple case when then multiple statement example in SQL query.

In this post, You'll learn use case statement in when in MySQL. i will show you use of case statement in MySQL query example function with example.

Here i will give you many example for case when function in MySQL query.

So let's see bellow solution:

Table: users_payment


So, let's see bellow solution:

Solution SQL Query:

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

Output:

I hope it will help you...