Skip site navigation (1) Skip section navigation (2)


From: D(dot)C(dot) <coughlandesmond(at)yahoo(dot)fr>
To: pgsql-novice(at)postgresql(dot)org
Subject: concepts?
Date: 2005-05-16 07:16:23
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
X-No-Archive: true

Hi again,
My test database is taking shape, and I'm starting to get the hang of 
it, but there's one concept that I just can't get my head around, and 
it is this: if I do ..

test=> select *  from people, job;

.. why does every entry get displayed seven times (there are seven 
'people' in each table) ?

In other words, why do I *need* to do this ..

test=> select * from people, job where = ;

... in order for every name to be displayed just once ?

Then if I do this ...

test=> select DISTINCT people.nom,people.prenom,job.boite, 
secteur.description from people, job, secteur where job.secteur_id = 

... every single person gets printed seven times, with their belonging 
to each sector of activity.  :-(   So I get 42 rows, whereas I only 
want seven: one for each person, with their name, their first name, 
their company name, and the 'sector' in which that company fits.  For 
example, my wife is a teacher, and so she appears as 'SMITH JOAN 
TEACHING CIVIL_SERVICE.  Perfect.  Except that she also gets listed as 
working for the *other* six companies in the db, and as belonging to 
their respective sectors.

What am I doing wrong ?  :-(



pgsql-novice by date

Next:From: ann hedleyDate: 2005-05-16 08:36:14
Subject: Re: Can null values be sorted low?
Previous:From: Volkan YAZICIDate: 2005-05-15 17:51:48
Subject: Re: Fw: Re: [Win2k - Version 8.0.2] - StartupMessage Format Question

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group