title: SELECT id where min or max value from multiple columns
body: <p>I'm looking for a fast MySQL query <strong>that returns the id</strong> of the product with the lowest (<code>min</code>) or highest (<code>max</code>) price, compared to all price categories (<code>a, b, c</code> and <code>d</code>).</p>
  
  <p>I have a product table called <code>chocolate_stock</code> with several price categories. It's pretty easy to receive the lowest (<code>min</code>) or highest (<code>max</code>) price from a specific category (<code>a</code> or <code>b</code> or <code>c</code> or <code>d</code>). </p>
  
  <pre><code>id |      name       | price_a | price_b | price_c | price_d |
  --------------------------------------------------------------
  1  |   Chips Ahoy    |   250   |   530   |   720   |   120 
  --------------------------------------------------------------
  2  | Chocolate Chunk |   250   |   90    |  32.92  |   110   
  --------------------------------------------------------------
  3  |      Oreo       |   103   |  44.52  |   250   |   850   
  --------------------------------------------------------------
  </code></pre>
  
  <p>The price categories are <code>decimal(10,2)</code>. Here's a sample that returns the highest price from the categories, <em>but</em> not the id:</p>
  
  <pre><code>$t = 'chocolate_stock';
  $arrIds = array(1, 3);
  
  $strQuery = "SELECT id, 
               MAX(price_a) AS price_a, 
               MAX(price_b) AS price_b, 
               MAX(price_c) AS price_c, 
               MAX(price_d) AS price_d 
               FROM $t WHERE id IN(". implode(',', array_map('intval', $arrIds)) .")";
  </code></pre>
  
  <p>What is the fastest way to retrieve this information?</p>