I am attempting to write a MySQL query that checks a database for a true/false flag, indicated by a 1 or 0. I would like to use an internal MySQL function to return the word "Yes" or the word "No" if the value is 1 or 0. Is this possible in MySQL?

    SELECT IF(myBinaryField=1,'Yes,'No')
    FROM mytable

      Or with a CASE statement, which follows the ansi92 spec -

      SELECT CASE myfield WHEN 1 THEN 'Yes'
      ELSE 'No' END
      FROM table

        Write a Reply...