title: SQL SELECT rows from one table using an array taken from another table
body: <p>I need to do something like this:</p>
  
  <pre><code>$user_id = (int) get_logged_in_userud();
  
  **$thread_ids** = $wpdb-&gt;query( "SELECT thread_id FROM $tableName1 WHERE user_id = %s), $user_id);
  
  $iterateRows = $wpdb-&gt;query( "SELECT thread_id FROM $tableName2 WHERE thread_id IN $s), **$thread_ids**);
  </code></pre>
  
  <p>I tried to grab it this way, but it returns an array in an array and each row is an associative array.  Once I have this data I need to iterate through all the selected rows with something like a while loop.  </p>
  
  <p>I did try and do this on my own first, and came up with the below code.  But its not in a usable format.  I need to echo through each item like $row['col_name']; for each column.  The goal is to list all messages that match a thread_id and user_id.  </p>
  
  <pre><code>$grabThreadList = $wpdb-&gt;query( $wpdb-&gt;prepare("SELECT A.* FROM $recipientTableName WHERE A.thread_id IN (SELECT B.thread_id FROM $senderTableName WHERE B.thread_is = A.thread_id "));
  
      foreach ($grabThreadList as $key =&gt; $value){
  
      $implodeMe = implode(',,,few ', $value);
  
  }
  </code></pre>