I’m trying to update multiple rows by using GROUP BY but something is wrong?
In my db table I always have 2 rows with the same game_id like this:
id fk_game_id invite accepted
1 34 1 0
2 34 0 0
3 57 0 0
4 57 0 0
5 89 0 1
6 89 0 1
7 92 0 0
8 92 0 0
9 96 0 0
10 96 1 0
Now, what I want is to update all fk_game_id where none of them has 1 in invite, in this case the games with fk_game_id 57 and 92.
I have tried this but with no luck:
$sql = mysql_query("SELECT * FROM ".$prefix."_test_gameplayer WHERE invite=0 AND accepted = 0 GROUP BY fk_game_id");
while($row = mysql_fetch_assoc($sql)){
$thisgame = $row['fk_game_id'];
echo $row['fk_game_id'].' - Invite: '.$row['invite'].'<br>';
mysql_query("UPDATE ".$prefix."_test_gameplayer SET accepted=1 WHERE fk_game_id=$thisgame");
}
Please help and thanks in advance