Use CASE statement in SELECT in MySQL

Sometimes you might want to replace numbers with an enumerate value. ┬áLet’s take an example with a BIT field for HasChildren.

SELECT Name, IsParent
CASE
WHEN HasChildren=1 THEN ‘Parent’
WHEN HasChildren=0 THEN ‘Not parent’
ELSE ‘Unknown’ END AS IsParent
FROM Person

MySQL SELECT equivalent of SHOW PROCESSLIST

If you want the ability to sort or filter the SHOW FULL PROCESSLIST command, here’s the SQL equivalent:

SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST