title: MySQL IF ELSE Look over
body: <p>I have a stored procedure that use if elseif else in MySQL.  In the first one, no matter what params I pass in, I get null. Can anyone help me out?</p>
  
  <pre><code>CREATE DEFINER=`root`@`localhost` PROCEDURE `CBattle`(IN btle varchar(50), OUT coun1 varchar(50), OUT coun2 varchar(50))
  BEGIN
  DECLARE shipnum int;
  IF 2 != (SELECT COUNT(classes.country) FROM classes, outcomes, ships WHERE outcomes.ship = ships.name AND ships.class = classes.class AND outcomes.battle = btle )
  THEN 
  SET coun1 = null;
  SET coun2 = null;
  ELSE 
  SET coun1 = (SELECT country FROM classes, outcomes, ships WHERE outcomes.ship = ships.name AND ships.class = classes.class AND outcomes.battle = btle LIMIT 1);
  SET coun2 = (SELECT country FROM classes, outcomes, ships WHERE outcomes.ship = ships.name AND ships.class = classes.class AND outcomes.battle = btle LIMIT 1,1);
  END IF;
  END
  </code></pre>