MySQL Case When Multiple Conditions Example
Hello Friends,
This article will give you example of MySQL case statement multiple conditions. I explained simply about how to use case statement in MySQL. This tutorial will give you simple case with multiple conditions SQL query.
In this post, You'll learn use case when in MySQL with multiple conditions. i will show you use of MySQL case when multiple conditions.
Here i will give you many example for MySQL case statement with multiple conditions.
So let's see bellow solution:
Table: user_payments
So, let's see bellow solution:
Solution SQL Query:
SELECT
id,
user_id,
charge,
CASE WHEN status = 1 THEN 'PAID'
WHEN status = 2 THEN 'FAIL'
WHEN status = 3 THEN 'WAIT'
ELSE 'PENDING'
END as status
FROM `user_payments`
Output:
I hope it will help you...
- How to Increase max_connections in MySQL?
- How to Install the PHP PDO MySQL Extension on Ubuntu 22.04?
- How to Install PHP MySQL on Linux Ubuntu?
- How to Install LEMP Stack Nginx, MySQL, PHP on Ubuntu?
- How to Change MySQL Root User Password Ubuntu?
- PHP 8 MySQL Form Validation Example
- How to Select First Row Only in PHP MySQL?
- How To Backup MySQL Database Using PHP Example