We can use conditions while selecting data using CASE, ELSE Statement. In this lesson, I will show you how we can provide conditions at the time of selecting data.
CASE Syntax:
CASE
WHEN condition THEN output
WHEN antoher_condition THEN anohter_output
ELSE output
END;
SELECT email,
CASE
WHEN gender = 'male' THEN CONCAT('Mr. ', name)
WHEN gender = 'female' THEN CONCAT('Miss. ', name)
ELSE name
END as name
FROM employees;