Re: [newbie] Relations...

From: "Thalis A(dot) Kalfigopoulos" <thalis(at)cs(dot)pitt(dot)edu>
To: John Moo <projects(at)bitnet-nospam(dot)pl>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [newbie] Relations...
Date: 2001-06-12 18:58:42
Message-ID: Pine.LNX.4.21.0106121457530.19889-100000@aluminum.cs.pitt.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 5 Jun 2001, John Moo wrote:

> 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.

You have to add a condition to ask for the particular name i.e. add a WHERE clause.

Check http://www.postgresql.org/idocs/index.php?queries.html to refhresh your sql :-)

cheers,
thalis

>
> Thanks for help
> John Moo
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Doug McNaught 2001-06-12 19:05:53 Re: Q: pgaccess + restoring a table from a previous txt export
Previous Message Thalis A. Kalfigopoulos 2001-06-12 18:50:42 Re: Exploring sequences (sequence context within a transaction)