我有喜欢/不喜欢游戏的表格:id
, game_id
, type
(喜欢/不喜欢),time
表格示例:图片链接
这段代码给了我上周喜欢的游戏,按他们的喜欢计数排序:
$limit = 10;
$time = _time() - 60*60*24*7;
$games_id = array();
$games_id_query = $this->db->execQuery("SELECT `game_id`, count(*) as `likes_count` FROM `likes` WHERE `type` = 'like' AND `time` > '{$time}' group by `game_id` order by `likes_count` DESC LIMIT {$limit}");
$games_id_num = $games_id_query->num_rows;
if($games_id_num > 0) {
while($row = $games_id_query->fetch_object()) {
unset($row->likes_count);
$games_id[] = (array) $row;
}
}
我需要添加此代码。我想要一个更多的订单,这将是这个 game_id 的不喜欢计数,ASC。
我该怎么做?仅使用 SQL...非常感谢!