title: How to correlate data from two separate tables
body: <p>I am a beginner at SQL. I am trying to write the following statement, but where user is in group (so where <code>group_members</code>.<code>user_id</code> = $_SESSION['user_id']).</p>
  
  <pre><code>SELECT `group_name`, `group_description` FROM `groups`
  </code></pre>
  
  <p>How do I write this sort of query that relates values from two different tables? Sorry if I haven't explained this well.</p>
  
  <p>EDIT: When I use the query provided by Matthew Haugen, I seem to have the following difficulty: only one set of results is returned in an array.</p>
  
  <p>This is my code for the function that does the query:</p>
  
  <pre><code>function group_summary(){
  $sql = secure_mysqli("SELECT `group_name`,`group_description` FROM `groups` WHERE `group_id` IN (SELECT `group_id` FROM `group_members` WHERE `user_id` = ?)", array($_SESSION['user_id']), "i");
  $groups = $sql;
  return $groups;
  }
  </code></pre>
  
  <p>And this is secure_mysqli:</p>
  
  <pre><code>function secure_mysqli($query, $values, $datatypes) {
      global $link;
      $stmt = mysqli_prepare($link, $query);
      if($stmt !== false){
      if(is_array($values)){ foreach ($values as &amp;$value) $ref_values[] = &amp;$value;
      call_user_func_array("mysqli_stmt_bind_param", array_merge(array($stmt, $datatypes), $ref_values));
      mysqli_stmt_execute($stmt);
      return @mysqli_fetch_assoc(mysqli_stmt_get_result($stmt));
  }}}
  </code></pre>