title: MySQL IF Statements in Query issues
body: <p>I have the following query that I am trying to execute. It is the starting point for a query required to run a report:</p>
  
  <pre><code>SET @fname = 'Bob';
  SET @blah = 0;
  
  SELECT CASE WHEN @fname IS NULL THEN @blah = 1 ELSE @blah END;
  
  
      IF (@blah &gt; 0) THEN
         SELECT * FROM mytable
      END IF;
  </code></pre>
  
  <p>Something is apparently wrong with my syntax but I cannot figure it out. I've written other queries using IF statements without issue. This will not run in either SQLyog or Workbench. It says there is a sytax error on "IF" with or without the parens, doesn't matter.</p>
  
  <p>All I need is the ability to evaluate a variable/input parameter in the IF statement.</p>
  
  <p>Any help is appreciated. <em>NOTE</em> - the SELECT CASE may not be necessary if I can get the IF to evaluate parameters properly but I was trying any possible solutions.</p>
  
  <p>Thanks</p>