title: MySQL query to check a row's cells for value and return column name
body: <p>I have been struggling with a certain query all day and I decided to ask for help.</p>
  
  <p>I need a query that checks an entire table row and all its table cells for a value 'yes' and then it needs to give me the names of the columns where this is true.</p>
  
  <p><a href="https://i.stack.imgur.com/8g4RQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8g4RQ.png" alt="example table"></a></p>
  
  <p>To clarify with an example:
  in the table above I need to check the fruit row for all the cells with the value 'yes' and have the corresponding column names returned to me. In this case the result would be 'banana', 'apple' and 'pear'.</p>
  
  <p>I hope that example helps.</p>
  
  <pre><code>-- pseudo code
  SELECT `COLUMN_NAMES`
  FROM `My_Table`
  ROW `fruit`
  WHERE `value` = 'yes';
  </code></pre>
  
  <p>I'd also like to note that I can't rearrange my database. The db structure can't be changed because we are already doing queries like SELECT 'property' WHERE 'Banana' = 'yes'(which would return 'fruit'). I need it to work the other way around too.</p>