title: PHP order by another table with added count
body: <p>How do order by another table's column and get the count from  other table column so I can order by that. </p>
  
  <p>For example: </p>
  
  <pre><code>$sql="SELECT * FROM photos, views WHERE photos.unqid = views.photoid ORDER BY CAST(views.id AS SIGNED)";
  </code></pre>
  
  <p>I want to add the views to  the photos. So that photos are order by the views. </p>