MySQL: Using if statements for data conversion in a SELECT

I have an integer field in my database that I'd like to display as Yes/No in a report. You can do this conversion in your front end code, or you can use a MySQL if statement to do the conversion for you.

SELECT IF(CustPrimary = 1,'Yes','No') AS CustPrimary FROM Customer;


Note: Replies will be formatted with PHP Markdown Extra syntax.

Name: Email (Not Required):
 
Logged IP: 34.234.83.135
To prevent spam please submit by clicking the kitten: