title: How to combine two tables in a query
body: <p>I have two tables. The first is <em>user</em>; this consists of <em>username</em> and <em>userid</em>. The second is <em>search</em> which consists of <em>userid</em> and <em>query</em>.</p>
  <p>When I select the search table I want user ID to be replaced by username by taking the data from the user table. Is this making sense?</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>userid</th>
  <th>username</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>foo1</td>
  </tr>
  <tr>
  <td>2</td>
  <td>foo2</td>
  </tr>
  <tr>
  <td>3</td>
  <td>foo3</td>
  </tr>
  <tr>
  <td>4</td>
  <td>foo4</td>
  </tr>
  </tbody>
  </table>
  </div><div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>userid</th>
  <th>query</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>blah1</td>
  </tr>
  <tr>
  <td>2</td>
  <td>blah2</td>
  </tr>
  <tr>
  <td>3</td>
  <td>blah2</td>
  </tr>
  <tr>
  <td>4</td>
  <td>blah2</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Is there a way to do this with a single query?</p>