mysql select query set value as text based on the number we read from tablle.

SELECT
order_id,
order_status,
CASE
WHEN order_status = 1 THEN ‘Pending’
WHEN order_status = 2 THEN ‘Shipped’
WHEN order_status = 3 THEN ‘Delivered’
ELSE ‘Unknown Status’
END AS status_text
FROM orders;

Leave a Reply

Your email address will not be published. Required fields are marked *