Answer the question
In order to leave comments, you need to log in
How to group data by field in JOIN?
Hello.
I combine 2 tables using JOIN and I need to group the price field using GROUP BY by the game_id field (game number), but it doesn’t work out.
Here is a piece of the request, where I stopped at the moment and a screen that I receive.
SELECT * FROM `roulette_bets` LEFT OUTER JOIN `roulette_games` ON `roulette_bets`.`game_id` = `roulette_games`.`id` WHERE `roulette_bets`.`user_id`=36454 GROUP BY roulette_bets.id
ORDER BY `roulette_bets`.`game_id` DESC
SELECT roulette_bets.game_id, roulette_bets.user_id, SUM(roulette_bets.price) as pricebets FROM `roulette_bets` JOIN `roulette_games` ON `roulette_bets`.`game_id` = `roulette_games`.`id` WHERE `roulette_bets`.`user_id`=36454 GROUP BY roulette_bets.game_id
ORDER BY `roulette_bets`.`game_id` DESC
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question