From: | "Jerzy Kut" <jerzyk(at)inquad(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: [newbie] Relations... |
Date: | 2001-06-05 21:37:12 |
Message-ID: | 9fjjen$2p3p$1@news.tht.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi!
I don't know if i understand of your problem but i think You try to do
natural join on referenced attributes from both tables. Case explained by
You looks like cross join. Try to do:
SELECT name,title,body,date FROM accounts,news WHERE author=login;
All should works fine.
But sorry if i give trivial solution - maybe i don't understand...
Best regards.
Jerzy Kut
"John Moo" <projects(at)bitnet-nospam(dot)pl> wrote in message
news:9fj785$81j$1(at)news(dot)tpi(dot)pl(dot)(dot)(dot)
> I have a real stupid (propably) problem :)
> I have two tables, one holding accounts:
>
> CREATE TABLE accounts (
> login varchar(32) primary key,
> password varchar(32),
> name varchar(128),
> email varchar(64));
>
> and one holding posts (to news system):
>
> CREATE TABLE news (
> author varchar(32) references accounts(login),
> title varchar(32),
> body text,
> date timestamp default now(),
> id serial);
>
> ...and I want using _one_ SQL SELECT get all news rows but with
> accounts.name relation.
> "SELECT name,title,body,date FROM accounts,news" doesn't work fine,
> because it gets all rows from accounts table.
>
> Thanks for help
> John Moo
>
From | Date | Subject | |
---|---|---|---|
Next Message | Manuel Sugawara | 2001-06-05 21:39:55 | Re: Current database name |
Previous Message | Jerzy Kut | 2001-06-05 21:18:26 | Which of latest version is stable ? |