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

Re: exclusion query

From: Louis-David Mitterrand <vindex+lists-pgsql-sql(at)apartia(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: exclusion query
Date: 2008-09-22 14:45:03
Message-ID: 20080922144503.GA2788@apartia.fr (view raw or flat)
Thread:
Lists: pgsql-sql
On Mon, Sep 22, 2008 at 04:34:14PM +0200, Louis-David Mitterrand wrote:
> Hi,
> 
> I've got five related tables:
> 
> - person_type:
> 	id_person_type 	integer
> 	type_fr			text
> 
> - person:
> 	id_person 		integer
> 	...
> 
> - person_to_event:
> 	id_person 		-> person
> 	id_person_type 	-> person_type (e.g: actor, director, producer, ...)
> 	id_event		-> event
> 
> - event:
> 	id_event		integer
> 	id_event_type	-> event_type
> 	...
> 
> - event_type:
> 	id_event_type	integer
> 	type_fr			text
> 
> To select person_type's used in a certain event_type I have this query:
> 
> select distinct pt.type 
>         from person_type pt 
>         natural join person_to_event 
>         join event e using (id_event) 
>         natural join event_type et 
>         where et.type_fr='théâtre';
> 
> Now, I'd like to select person_type's _not_ used in a certain particular
> event (say id_event=219).

To be more precise: not used in a particular event _but_ used in other
events of type 'theatre'.

> I can see how to build a quey to that effect, but is there a more
> obvious, clean, short solution? Something that looks like the above
> query maybe?
> 
> Thanks,
> 
> -- 
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql

In response to

pgsql-sql by date

Next:From: Mark RobertsDate: 2008-09-22 16:39:08
Subject: Re: exclusion query
Previous:From: Louis-David MitterrandDate: 2008-09-22 14:34:14
Subject: exclusion query

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