I have two conditions that are causing the CASE statement not to work as intended. I've tried changing which condition comes first, but it still only proceeds with one of them. Any suggestions?
CASE statement that returns only the value before the first '(' and replaces all instances of 'Metallic' with 'M':
CASE
WHEN `order_option`.`value` LIKE '%(%)%' THEN SUBSTRING_INDEX(`order_option`.`value`,' (', 1)
WHEN `order_option`.`value` LIKE '%Metallic%' THEN REPLACE (`order_option`.`value`,'Metallic','M')
ELSE `order_option`.`value`
END AS `Option`,
Current data
`value`
--------
Red Metallic (999)
Blue (745)
Expected results
`Option`
--------
Red M
Blue
Thank you in advance!
value
; your data mentionsOption
. TheLIKE
looks for just(
, but theSUBSTRING_INDEX
looks for ` (`.