title: SQL Order By Column From another Table
body: <pre><code>$sql = "SELECT user2 FROM subscriptions WHERE user1 = '$username'";
  </code></pre>
  
  <p>This code works perfectly, but what I would like to do is ORDER it BY a column from my users table, the user_id column. Now I can't do this…</p>
  
  <pre><code>$sql = "SELECT user2 FROM subscriptions WHERE user1 = '$username' ORDER BY user_id";
  </code></pre>
  
  <p>Because there is no column called user_id in my subscriptions table, just in my users table.</p>