vendredi 19 décembre 2014

MySQL: possible to combine CASE forms?


I know that there are two different CASE forms available, one for checking equality and one for checking expression results. Is it possible to combine the two? If not, any other suggestions? I'm imagining something like this:



SELECT
CASE
WHEN foo LIKE '%bar' THEN 'foobar'
WHEN foo = 'gob' THEN 'jobe'
END AS x;


...or...



SELECT
CASE foo
WHEN LIKE '%bar' THEN 'foobar'
WHEN 'gob' THEN 'jobe'
END AS x;


But I get syntax errors for both.





Aucun commentaire:

Enregistrer un commentaire