MySQL Case in Select Statement with LIKE operator

后端 未结 4 1509
隐瞒了意图╮
隐瞒了意图╮ 2021-02-01 13:32

Is it possible to combine the CASE statement and the LIKE operator in a MySQL SELECT statement?

For Example, I am trying to query

4条回答
  •  甜味超标
    2021-02-01 13:54

    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
    

提交回复
热议问题