Sorry for posting so much but you guys are helpful and I don't know what I should be searching for as admittedly my SQL skills aren't great.
I'm trying to get my pieces out of my database table in order to display them; I'm using blocks and php. I have my piece data including what kind of piece it is, its position and its owner in the piece table but I'm storing the color each player has for their pieces in the player table (and I need the color information in order to display the right image).
I've only got pieces in the table for a single player atm. A player can have many pieces of a given type and they're all valid (ie you can have 8 pawns in chess). I've just got pieces hard coded in the setup for now. When I run my query, no matter what I try, it's only pulling one piece per TYPE. (ie it's giving me a single pawn instead of 8, single rook instead of 2, etc.)
Is there something obvious I'm missing?
SELECT pieces.piece_type kind, pieces.player_id id, pieces.piece_x x, pieces.piece_y y, player.player_color color, player.player_id
FROM pieces
LEFT JOIN player ON pieces.player_id = player.player_id
I could store the color data in the piece table but it seems silly to have it in multiple places like that when having the owner is more important. I don't even know if I'm investigating the right thing or not since it is pulling the color data for what its pulling; it's just not pulling all of the pieces.
thx.
I'm trying to get my pieces out of my database table in order to display them; I'm using blocks and php. I have my piece data including what kind of piece it is, its position and its owner in the piece table but I'm storing the color each player has for their pieces in the player table (and I need the color information in order to display the right image).
I've only got pieces in the table for a single player atm. A player can have many pieces of a given type and they're all valid (ie you can have 8 pawns in chess). I've just got pieces hard coded in the setup for now. When I run my query, no matter what I try, it's only pulling one piece per TYPE. (ie it's giving me a single pawn instead of 8, single rook instead of 2, etc.)
Is there something obvious I'm missing?
SELECT pieces.piece_type kind, pieces.player_id id, pieces.piece_x x, pieces.piece_y y, player.player_color color, player.player_id
FROM pieces
LEFT JOIN player ON pieces.player_id = player.player_id
I could store the color data in the piece table but it seems silly to have it in multiple places like that when having the owner is more important. I don't even know if I'm investigating the right thing or not since it is pulling the color data for what its pulling; it's just not pulling all of the pieces.
thx.