title: MySQL - PHP order by the Inner Joining table id rather than the Selected table ID?
body: <p>I have following query which i want to order by the UserView ID descending, seems like pretty basic question but i cant figure out how to do it, i want keep selecting the User.* as it now, but order by the UsersView table primary key desc, Any ideas ?</p>
  
  <pre><code> $phql = " SELECT *
                        FROM User
                        WHERE user_id IN
                        ( SELECT user_to
                          FROM UsersView
                          WHERE user_from=:user_to: )
                        AND gender!=:gender:
                        AND user_id NOT IN (".implode(",",$this-&gt;user-&gt;getBlocked()).")
                        ORDER BY last_visit DESC
                   /* order by should be usersview.id DESC */ 
                        "; 
  </code></pre>
  
  <p>Any luck with this ?</p>