title: How to retrieve multiple rows from stored procedure in MySQL?
body: <p>Am trying to fetch out a field through stored procedure and I used following query. I aimed at fetching out multiple rows, but it executes the result successfully only when a single row exists. Or else it returns an error as I mentioned below.</p>
  <h3>MySQL Query</h3>
  <pre><code>DELIMITER ;;
  DROP PROCEDURE IF EXISTS Sample1;;
  
  CREATE PROCEDURE Sample1(IN lft1 INT, IN rgt1 INT, OUT emp1 VARCHAR(20))
  BEGIN
      SELECT p.emp INTO emp1
      FROM personnel p
      WHERE p.lft &gt; lft1
            AND p.rgt &lt; rgt1
      LIMIT 10;
  END;;
  
  CALL Sample1(1, 10, @emp);;
  SELECT @emp;
  </code></pre>
  <h2>Error Message</h2>
  <pre><code>MySQL said: Documentation
  #1172 - Result consisted of more than one row 
  </code></pre>
  <hr />
  <h2>NOTE</h2>
  <blockquote>
  <p><code>Sample1</code> - procedure name<br />
  <code>emp</code> - selected field from table personnel<br />
  <code>lft</code> - use to check the condition, it is also one of the field of table personnel<br />
  <code>personnel</code> - table name</p>
  </blockquote>