I'm trying to make a column in mysql called group if from the second through the third position of the string matches exactly 07. For instance, the string a07ha should be categorized as 07 since this satisfies the condition. This gives me an error. I guess I'm messed up with the = '07' part. Any advice would be of great help.
SELECT
CASE WHEN 'a07ha' REGEXP '^{2,3}' = '07' THEN '07'
ELSE '00'
END AS group
REGEXPdoesn't return the matching part, it just returnsTRUEorFALSE.$matches the end of the string.SUBSTR(column, 2, 2)?{2,3}without a pattern before it. It means 2-3 repetitions of the preceding pattern.