I am currently working on a project and I need help with a query.
I need to count the number of players associated to a game, but minus 1 if your id appears in the list.
Here is my current query
Code: Select all
$query = "SELECT `games`.*, COUNT(`user_games`.`user_id`) AS `players` FROM `games`, `user_games` WHERE `duplicate`=0 AND `user_games`.`game_id`=`games`.`id` GROUP BY `app_name` ORDER BY `app_name`";
if the users id appears as one of the user ids in user_games, then minus 1 from the count.
I dont really want to split the query up unless there really is no other way, but I am sure there is.
ta xx