Control Flow Functionsmysql
• CASE value WHEN [compare_value] THEN result [WHEN [compare_value] THEN result ...] [ELSE result] ENDsql
SELECT * FROM table LEFT JOIN x ON x.id = table.id LEFT JOIN (SELECT id, CASE table.x WHEN 1 THEN "tablea" WHEN 2 THEN "tableb" WHEN 3 THEN "tablec" END FROM tablex) AS tmpe ON tmpe.id = table.n WHERE table.id = "hello" LIMIT 1;