Hi Geoff, On Mon, Oct 31, 2016 at 4:21 PM, Geoff Winkless <pgsqlad...@geoff.dj> wrote:
> > You could break the game table apart into game and gameplayer. > > That's more "normal" and fits much more nicely, IMO, and you could > then resolve the CASE by using joins between game and (twice) > gameplayer: > > SELECT ... > FROM game INNER JOIN gameplayer AS myplayer ON > game.gameid=myplayer.gameid AND myplayer.uid=in_uid > INNER JOIN gameplayer AS otherplayer ON game.gameid=otherplayer.gameid > AND otherplayer.uid!=in_uid > ... > > Then all the other tables simply join to myplayer and otherplayer. > > do you mean, instead of having player1, player2 columns in the words_games table (as in my current schema https://gist.github.com/afarber/c40b9fc5447335db7d24 ) - I should move the player stuff (uid, hand, score) to a separate table and then JOIN them? Regards Alex