From: | Raymond O'Donnell <rod(at)iol(dot)ie> |
---|---|
To: | 'PostgreSQL' <pgsql-general(at)postgresql(dot)org> |
Subject: | SQL question: checking all required items |
Date: | 2007-08-10 20:07:26 |
Message-ID: | 46BCC57E.7090708@iol.ie |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi all,
Given the following tables -
create table people (
person_id text primary key,
person_name text,
[...etc...]
);
create table items (
item_id text primary key,
item_name text,
is_required boolean,
[...etc...]
);
create table items_for_people (
person_id text,
item_id text,
primary key (person_id, item_id),
foreign key person_id references people(person_id),
foreign key item_id references items(item_id)
);
- how can I find those people who don't have _all_ of the items which
are marked "required"?
In other words, how do I select those rows in "people" which don't have
a corresponding row in "items_for_people" for *each* row in "items"
which has is_required=true?
Many thanks,
Ray.
---------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod(at)iol(dot)ie
---------------------------------------------------------------
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Marlowe | 2007-08-10 20:29:38 | Re: SQL question: checking all required items |
Previous Message | Vivek Khera | 2007-08-10 19:42:58 | Re: Dell Hardware Recommendations |