title: MySQL Assign Return Value to Variable
body: <p>How do you declare variable and set a value which is a return from a query on them later.</p>
  
  <p>Sample Stored Procedure:</p>
  
  <pre><code>DELIMITER $$
  
  CREATE PROCEDURE `sampledb`.`SetVariableEx`()
  
      BEGIN
  
          -- declare variable
          DECLARE xVarA INT;                
          DECLARE xVarB INT;      
  
          -- in this line, i would like to set a value on xVarA which is a COUNT
          -- of record from table SINGLETABLE
          -- i am getting error on this line.
          SELECT xVarA := COUNT(*) FROM SingleTable;
  
          -- the value of xVarA is added by 1 and set it to xVarB
          SET xVarB = xVarA + 1;
  
          -- insert the value of xVarB to the table SINGLETABLE
          INSERT INTO SingleTable(SingleColumn) VALUES (xVarB);
  
          -- lastly, display all records.
          SELECT * FROM SingleTable;
  
      END$$
  
  DELIMITER ;
  </code></pre>
  
  <p>how would i do that?</p>