Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何按另一个表的列排序并从其他表列获取计数,以便我可以按此排序。
例如:
$sql="SELECT * FROM photos, views WHERE photos.unqid = views.photoid ORDER BY CAST(views.id AS SIGNED)";
我想将视图添加到照片中。所以照片是按视图排序的。
类似于以下内容
SELECT p.*, v.*, COUNT(v.photoid) as nb_views FROM photos p, views v WHERE p.unqid = v.photoid GROUP BY v.photoid ORDER BY nb_views