From: Patrick JACQUOT (DSI NOISIEL) <patrick.jacquot@anpe.fr>
To: pgsql-sql@postgresql.org
Subject: Re: Please help me to slove this SQL statements
Date: Wed, 5 Nov 2003 10:34:24 +0100
Message-ID: <D6C9336C2DB19B43BC3BABDCCFEB7282F2A0CC@EX-BAL-01.anpe.fr> (raw)
-----Message d'origine-----
De : Freshman [mailto:abc@msn.com]
Envoyé : jeudi 30 octobre 2003 13:38
À : pgsql-sql@postgresql.org
Objet : [SQL] Please help me to slove this SQL statements
There are three table in database which is suppliers, projects, and
shipments
suppliers contain suppliers id, name ...etc
projects contain project name ..suppliers ID ( J1---J7) ...etc
shipments table contain suppliers ID , PROJECTS ID
how can i query to find out the suppliers to supply all the projects ID
I would suggest:
SELECT * from suppliers
WHERE NOT EXISTS(
SELECT * FROM projects
WHERE NOT EXISTS(
SELECT * from shipments
WHERE shipments.suppliers_ID = suppliers_suppliers_id
AND shipments.project_ID = project.project_id
)
);
so you select every supplier who didn't miss any project.
Is that you want to do?
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: patrick.jacquot@anpe.fr
Subject: Re: Please help me to slove this SQL statements
In-Reply-To: <D6C9336C2DB19B43BC3BABDCCFEB7282F2A0CC@EX-BAL-01.anpe.fr>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox