title: How to return a MySQL array of results without using a PHP loop
body: <p>I'm trying to join this query with another, but that will require doing everything at once without leaving this statement. </p>
  
  <p><strong>MYSQL</strong></p>
  
  <pre><code>"SELECT pid FROM posts WHERE uid = ? &amp;&amp; state = 'a' ORDER BY time DESC LIMIT 5"
  </code></pre>
  
  <p><strong>Using PHP's while.</strong> </p>
  
  <pre><code>while($row = $get-&gt;fetch()){
      echo $row['pid'].' ,';
  }
  </code></pre>
  
  <p>I get something like : 2,5,8,31,40</p>
  
  <p>Is there a way to get the same values without getting out of the query? </p>
  
  <p>Something like <strong>SELECT as returned_values</strong></p>
  
  <p>So I could do : <code>$row['returned_values'];</code> and get : "2,5,8,31,40"</p>