mysql SELECT IF statement with OR

MysqlSqlSelectIf Statement

Mysql Problem Overview


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

Mysql Solutions


Solution 1 - Mysql

Presumably this would work:

IF(compliment = 'set' OR compliment = 'Y' OR compliment = 1, 'Y', 'N') AS customer_compliment

Solution 2 - Mysql

IF(compliment IN('set','Y',1), 'Y', 'N') AS customer_compliment

Will do the job as Buttle Butkus suggested.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRobbo_UKView Question on Stackoverflow
Solution 1 - MysqlDigbyswiftView Answer on Stackoverflow
Solution 2 - MysqlAleXqwqView Answer on Stackoverflow