title: MySQL Sorting By Three Columns in DESC Order
body: <p>I am relatively new to MySQL and I am having difficultly trying to sort a table by three columns.</p>
  
  <p>It is a database that has stored data for thousands of videos and I would like to create a tab on my website that lists recommended videos to the user.</p>
  
  <p>If possible, it would be optimal to only sort the last 100 most recently added videos (records) which have been auto incremented by the 'key' column.</p>
  
  <p>Out of the 100 ordered records, I will only actually retrieve five records from the database and store them into PHP variables.</p>
  
  <p>I am trying to get it to sort the columns as follows.</p>
  
  <pre><code>key DESC
  rating_score DESC
  view_count DESC
  </code></pre>
  
  <p>I previously used another MySQL statement that sorts videos by two columns that works.</p>
  
  <pre><code>SELECT  `title`, `duration`, `rating_score`, `imageurl`, `player_url` FROM (SELECT * FROM `archived_videos` ORDER BY `key` DESC LIMIT 0,210) AS ttbl ORDER BY `rating_score` DESC
  </code></pre>
  
  <p>My current and modified version of the above MySQL statement that sorts by three columns is written as follows.</p>
  
  <pre><code>SELECT  `title`, `duration`, `rating_score`, `imageurl`, `player_url` FROM ((SELECT * FROM `archived_videos` ORDER BY `key` DESC LIMIT 0,100) AS ttbl (SELECT * FROM `archived_videos` ORDER BY `view_count` DESC) AS ttbl) ORDER BY `rating_score` DESC LIMIT 0,5
  </code></pre>
  
  <p>If someone who is fluent in MySQL could take a look at this you would be a life saver.</p>