title: mysql stored procedure construct with GROUP_CONCAT and IN clause
body: <p>For some reason i need to explode a query in multisteps (very large rows and many join) , <strong>I know its possible to perform the query like SELECT IN (subquery) but its not what i need to achieve.</strong></p>
  
  <p>How to construct my query into step where query 2 can use the result of query 1 (without using temporary table) with an IN clause ; expected query 2 should look like this : select otherstuff where foo IN(id,id,id,id,longlistid,)</p>
  
  <p>query 1 => select stuf as result1 <br>
  query 2 => select otherstuf where foo IN (result1)</p>
  
  <p><strong>I thought to use shortcut @ don't know if its appropriate , here is my try :</strong></p>
  
  <pre><code> CREATE PROCEDURE `exemple`()
      BEGIN
  
       SELECT @query1 := 
      `id`  FROM `table`
      WHERE `stuf`= 'cat'
      UNION ALL SELECT `id`
      FROM `table`
      WHERE `dog`= 'hard' ;
  
      SELECT please FROM help WHERE me IN(@query1) ;
  
      END
  </code></pre>
  
  <p>The IN clause seems not correct like this..</p>
  
  <p><strong>Another try , store result in a declared locale variable :</strong></p>
  
  <pre><code>CREATE PROCEDURE `exemple`()
      BEGIN
  
       DECLARE resultquery1 VARCHAR(5000);
  
      SELECT 
      `id`  FROM `table`
      WHERE `stuf`= 'cat'
      UNION ALL SELECT `id`
      FROM `table`
      WHERE `dog`= 'hard' 
      INTO resultquery1 ;
  
      SELECT please FROM help WHERE me IN(resultquery1) ;
  
      END
  </code></pre>
  
  <p>Not enought , i got this logical error :
  Error Code: 1172. Result consisted of more than one row</p>
  
  <p>regards,
  Jess</p>