MySQL Case in Select Statement with LIKE operator
Solution 1:
Using the second form of CASE
should work:
SELECT
CASE
WHEN digits LIKE '6901%' THEN substr(digits,4)
WHEN digits LIKE '91%' THEN substr(digits,2)
END as digits
FROM raw
Furthermore, you have a stray comma at the end of your SELECT
.
Solution 2:
Try
SELECT
CASE true
WHEN digits LIKE "6901%" THEN substr(digits,4)
WHEN digits LIKE "91%" THEN substr(digits,2)
END as "digits",
FROM raw