title: Assigning query's results into variable inside MySQL procedure
body: <p>Here is the piece of sql from my procedure:</p>
  
  <pre><code>   .... 
     SET @list := (
          SELECT
              `i`.`id` 
          FROM
              `Item` AS `i`
          Order by RAND()
          LIMIT 10
          );
      RETURN CONCAT_WS( '-', @list );
  </code></pre>
  
  <p>Inside procedure, I need to set query's results (yes, query returns multiple rows as a result) into some variable. </p>
  
  <p>Then as a second variable, I need to concatenate previous results into one string. </p>
  
  <p>But when I do it, I get following error:</p>
  
  <p><code>Sub-query returns more than 1 row</code></p>
  
  <p>So the question is, what am I doing wrong?</p>
  
  <p>By the way, I know about <code>group_concat</code>. In second part of procedure, there is a requirement for checking if some id exists on this <code>@list</code> variable: <code>find_in_set(</code>item_id<code>, @list )</code> 
  And the query returns random results every time when I call it. 
  That's why, calling sub-query 2 times: 1 time as group concat string, second time just as list of results is not a solution for me. So, I need them as a set stored in variable.</p>