title: Right sinxats of: SELECT WITH VAR inside MySQL
body: <p>I'm trying a IF statement inside of SQL code but I'm getting a sintax error, SQL always mess up my thinking.</p>
  
  <p>What I'm trying is set a COUNT inside of a VAR and them use this VAR to define a UPDATE or INSERT command, something like:</p>
  
  <pre><code>SELECT COUNT(id) INTO @id FROM table1;
  IF @id &gt; 0 THEN 
    UPDATE
  ELSE
    INSERT;
  </code></pre>
  
  <p>Help is always wellcome.</p>