title: MySQL ORDER BY highest number of rows in another table
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/12730493/mysql-order-by-total-rows-of-user-in-another-table">MySQL ORDER BY total rows of user in another table</a>  </p>
  </blockquote>
  
  
  
  <p>I have 5 users (on table <code>users</code>):</p>
  
  <pre><code>User ID (uid) | User Name (uname)
  -----------------------------------
  1               Fallon
  2               Jeremy
  3               Matt
  4               Peter
  5               John
  </code></pre>
  
  <ul>
  <li>Fallon (uid 1) has logged in 35 times so far.</li>
  <li>Jeremy logged in 32 times.</li>
  <li>Matt logged in 57 times.</li>
  <li>Peter logged in 43 times.</li>
  <li>John logged in 23 times.</li>
  </ul>
  
  <p>Log details are stored in another table (<code>logs</code>):</p>
  
  <pre><code>Log ID (logid) - User ID (uid)
  </code></pre>
  
  <p>Now I want to represent a list of users in order of most logged times. The user who logged in the most will be at the top, second most logged user will be the second. Like:</p>
  
  <ol>
  <li>Matt logged in 57 times.</li>
  <li>Peter logged in 43 times.</li>
  <li>Fallon logged in 35 times.</li>
  <li>Jeremy logged in 32 times.</li>
  <li>John logged in 23 times.</li>
  </ol>
  
  <p>Because Logs are stored in one table and User details in another. How can I, What queries should I, use to make a list like the above. Please help.</p>