[eluser]goliatone[/eluser]
Hi there,
I'm using Simon Stenhouse's DataMapper library.
So i have created the tables in order to use the library, and everything works great but I now need a SQL query to export an Excel from phpmyadmin.
I have the following tables:
games
games_matches
matches
matches_players
players
I need to retrieve all players related to a game.
My query atm looks like this:
Code:
$sql = ' SELECT `players`. *'
. ' FROM ('
. ' `players` , `games`'
. ' )'
. ' LEFT JOIN `matches_players` ON `players`.`id` = `matches_players`.`player_id`'
. ' LEFT JOIN `games_matches` ON `games_matches`.`game_id` = 2'
. ' LEFT JOIN `matches` ON `matches`.`id` = `matches_players`.`match_id`'
. ' WHERE `games_matches`.`game_id` = 2'
. ' GROUP BY players.id'
. ' ORDER BY `players`.`name` ASC'
. ' LIMIT 0 , 30 ';
Obviously it's not working.
Any advice would greatly be appreciated!
regards,
goliatone