Change value from 1 To Yes In MySQL select statement

Rocco The Taco picture Rocco The Taco · Feb 21, 2014 · Viewed 24.5k times · Source

I'm only able to SELECT on a table.

The table has a column called inty with a value of 0 or 1

I am currently selecting inty as:

SELECT inty AS InternetApproved FROM Table1

Is there a way to reformat the data within the SQL SELECT so that if the value is 0 make it No and if the value is 1 make it Yes for display purposes in the output SELECT results?

Answer

Deepak Rai picture Deepak Rai · Feb 21, 2014

Simple and easy way to achieve this is:

SELECT IF(inty = 1, 'YES', 'No') AS internetApproved FROM Table1