title: IF and Case statements in MySQL
body: <p>I would like to select * if 5 is greater than 2, if false select a particular column. Where am I going wrong?</p>
  
  <pre><code>SELECT IF(5&gt;2, *, column_x),
  CASE whereheard_name WHEN 'Newspaper' THEN 'a'
           WHEN 'TV' THEN 'b' 
           WHEN 'Internet' THEN 'c'
           ELSE '-'
      END 
      AS result
  FROM whereheard;
  </code></pre>
  
  <p>Thanks for the answers to the above. Here is the following example stored procedure I am using:</p>
  
  <pre><code>DELIMITER $$
  
  USE `registration`$$
  
  DROP PROCEDURE IF EXISTS `test2`$$
  
  CREATE DEFINER=`root`@`localhost` PROCEDURE `test2`()
  BEGIN
      IF(5&gt;2) THEN
              SELECT * FROM whereheard;
          ELSE
              SELECT whereheard_name FROM whereheard;
          END IF;
  END$$
  
  DELIMITER ;
  </code></pre>
  
  <p>This is how I have called it:</p>
  
  <pre><code>CALL test2(),        
  CASE whereheard_name WHEN 'Newspaper' THEN 'a'
           WHEN 'TV' THEN 'b' 
           WHEN 'Internet' THEN 'c'
           ELSE '-'
      END 
      AS result
  FROM whereheard; 
  </code></pre>
  
  <p>Where am I going wrong with this?</p>