Re: [GENERAL] Saving score of 3 players into a table

2011-10-27 Thread David Johnston
Fair enough. But look in the SQL Commands section under SELECT (FROM clause) as well, as that gives you the syntax and meaning and not just an overview of the concept. David J. On Oct 27, 2011, at 8:27, Alexander Farber wrote: > The PostgreSQL docs are unfortunately scarce on JOINs > http:/

Re: [GENERAL] Saving score of 3 players into a table

2011-10-27 Thread Michael Glaesemann
On Oct 27, 2011, at 7:21, Alexander Farber wrote: > Thank you Michal and others - > > On Wed, Oct 26, 2011 at 11:11 PM, Michael Glaesemann > wrote: >> Get games for a particular user: >> >> SELECT g.gid, g.rounds, g.finished >> FROM pref_games g >> JOIN pref_scores u USING (gid) >> WHERE u.

Re: [GENERAL] Saving score of 3 players into a table

2011-10-27 Thread Alexander Farber
The PostgreSQL docs are unfortunately scarce on JOINs http://www.postgresql.org/docs/8.4/static/tutorial-join.html I've never seen a JOIN producing several rows instead of columns before Michael suggested it in this thread -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To

Re: [GENERAL] Saving score of 3 players into a table

2011-10-27 Thread David Johnston
-Original Message- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Alexander Farber Sent: Thursday, October 27, 2011 7:21 AM Cc: pgsql-general Subject: Re: [GENERAL] Saving score of 3 players into a table Thank you Michal and others - On

Re: [GENERAL] Saving score of 3 players into a table

2011-10-27 Thread Alexander Farber
Thank you Michal and others - On Wed, Oct 26, 2011 at 11:11 PM, Michael Glaesemann wrote: > Get games for a particular user: > > SELECT g.gid, g.rounds, g.finished >  FROM pref_games g >  JOIN pref_scores u USING (gid) >  WHERE u.id = :id; > > Now, add the participants for those games > > SELECT

Re: [GENERAL] Saving score of 3 players into a table

2011-10-26 Thread Michael Glaesemann
On Oct 26, 2011, at 16:15, Alexander Farber wrote: > Hello again, > > still I can't figure out how to perform a join > to fetch all games where a player has participated - > I have a table containing all games played: > > # select * from pref_games limit 5; > gid | rounds | finished >

Re: [GENERAL] Saving score of 3 players into a table

2011-10-26 Thread David Johnston
-Original Message- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Alexander Farber Sent: Wednesday, October 26, 2011 4:16 PM Cc: pgsql-general Subject: Re: [GENERAL] Saving score of 3 players into a table Hello again, still I can&#

Re: [GENERAL] Saving score of 3 players into a table

2011-10-26 Thread Alexander Farber
Hello again, still I can't figure out how to perform a join to fetch all games where a player has participated - I have a table containing all games played: # select * from pref_games limit 5; gid | rounds | finished -++ 1 | 10 | 2011-10-26

Re: [GENERAL] Saving score of 3 players into a table

2011-10-26 Thread Alban Hertroys
On 26 October 2011 10:08, Alexander Farber wrote: >    create table pref_games { >            gid serial, >            rounds integer not null, >            finished timestamp default current_timestamp >    } > then how do I find the new game id after I've just created it here: > >    create or

Re: [GENERAL] Saving score of 3 players into a table

2011-10-26 Thread Alexander Farber
Hello again, thank you for your replies. If I create a separate table for games: create table pref_users ( uid varchar(32) primary key, first_name varchar(64), female boolean, avatar varchar(128) } create table pref_games {

Re: [GENERAL] Saving score of 3 players into a table

2011-10-25 Thread Gavin Flower
On 26/10/11 08:32, Alexander Farber wrote: Hello, I'm trying to save results of card game with 3 players into a table. It is bad enough, that I had to introduce 3 columns for user ids: id0, id1, id2 and 3 columns for their scores: money0, money1, money2 - create table pref_results (

Re: [GENERAL] Saving score of 3 players into a table

2011-10-25 Thread Gavin Flower
On 26/10/11 08:32, Alexander Farber wrote: Hello, I'm trying to save results of card game with 3 players into a table. It is bad enough, that I had to introduce 3 columns for user ids: id0, id1, id2 and 3 columns for their scores: money0, money1, money2 - create table pref_results (

Re: [GENERAL] Saving score of 3 players into a table

2011-10-25 Thread Michael Glaesemann
On Oct 25, 2011, at 15:32, Alexander Farber wrote: > Hello, > > I'm trying to save results of card game with 3 players into a table. > > It is bad enough, that I had to introduce > 3 columns for user ids: id0, id1, id2 and > 3 columns for their scores: money0, money1, money2 - > >creat

Re: [GENERAL] Saving score of 3 players into a table

2011-10-25 Thread David Johnston
-Original Message- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Alexander Farber Sent: Tuesday, October 25, 2011 3:33 PM To: pgsql-general Subject: [GENERAL] Saving score of 3 players into a table Hello, I'm trying to save resul

[GENERAL] Saving score of 3 players into a table

2011-10-25 Thread Alexander Farber
Hello, I'm trying to save results of card game with 3 players into a table. It is bad enough, that I had to introduce 3 columns for user ids: id0, id1, id2 and 3 columns for their scores: money0, money1, money2 - create table pref_results ( id0 varchar(32) references pref