mysql SELECT IF statement with OR
122,663
Solution 1
Presumably this would work:
IF(compliment = 'set' OR compliment = 'Y' OR compliment = 1, 'Y', 'N') AS customer_compliment
Solution 2
IF(compliment IN('set','Y',1), 'Y', 'N') AS customer_compliment
Will do the job as Buttle Butkus suggested.
Author by
Robbo_UK
Updated on July 04, 2020Comments
-
Robbo_UK almost 4 years
The following works - returns Y when chargeback equal to 1 else it defaults to N
IF(fd.charge_back = 1, 'Y', 'N') AS charge_back
however I cannot seem to get this one working? Is the syntax valid
IF(compliment = ('set' OR 'Y' OR 1), 'Y', 'N') AS customer_compliment