Advertisement
elena1234

case statement in MySQL

Feb 20th, 2023
868
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.28 KB | Source Code | 0 0
  1. SELECT first_name, last_name,
  2. CASE
  3.   WHEN store_id = 1 and active = 1 THEN 'store 1 active'
  4.   WHEN store_id = 2 and active = 1 THEN 'store 2 active'
  5.   WHEN store_id = 1 and active = 0 THEN 'store 1 unactive'
  6.   ELSE 'store 2 unactive'
  7. END   AS 'store_and_status'
  8. FROM customer;
  9.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement