From: | John Poltorak <jp(at)eyup(dot)org> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | What am I doing wrong? |
Date: | 2001-01-16 12:10:29 |
Message-ID: | 20010116121028.A85@eyup.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
I think I'm doing something fundamenatally wrong when attempting
to use multiple tables. Can someone point out what I'm missing
from the following snippet:-
------------------------------------------
CREATE TABLE players
(player_id INTEGER NOT NULL Primary key,
player VARCHAR,
club_id INTEGER);
CREATE TABLE clubs
( club_id INTEGER NOT NULL Primary key,
club VARCHAR ,
foreign key (club_id) references players);
insert into players values (1, 'Rivaldo');
insert into players values (2, 'Kleivert');
insert into players values (3, 'Zidane');
insert into players values (4, 'Davids');
insert into clubs values (1, 'Barca');
insert into clubs values (2, 'Juve');
select player,club from players,clubs;
------------------------------------------
This is the output I get:-
player | club
----------+-------
Rivaldo | Barca
Kleivert | Barca
Zidane | Barca
Davids | Barca
Rivaldo | Juve
Kleivert | Juve
Zidane | Juve
Davids | Juve
(8 rows)
This is the output I would like:-
player | club
----------+-------
Rivaldo | Barca
Kleivert | Barca
Zidane | Juve
Davids | Juve
(4 rows)
It's probably obvious to everyone, but I don't see what I've done
wrong. Any enlightenment would be much appreiated.
--
John
From | Date | Subject | |
---|---|---|---|
Next Message | Tamsin | 2001-01-16 12:19:32 | RE: What am I doing wrong? |
Previous Message | Peter Rodriguez | 2001-01-16 06:01:46 | Table recognition |