pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedPlease help me to slove this SQL statements
2+ messages / 2 participants
[nested] [flat]
* Please help me to slove this SQL statements
@ 2003-10-30 12:38 Freshman <abc@msn.com>
0 siblings, 0 replies; 2+ messages in thread
From: Freshman @ 2003-10-30 12:38 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Please help me to slove this SQL statements
@ 2003-11-05 09:34 Patrick JACQUOT (DSI NOISIEL) <patrick.jacquot@anpe.fr>
0 siblings, 0 replies; 2+ messages in thread
From: Patrick JACQUOT (DSI NOISIEL) @ 2003-11-05 09:34 UTC (permalink / raw)
To: pgsql-sql
-----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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2003-11-05 09:34 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-10-30 12:38 Please help me to slove this SQL statements Freshman <abc@msn.com>
2003-11-05 09:34 Re: Please help me to slove this SQL statements Patrick JACQUOT (DSI NOISIEL) <patrick.jacquot@anpe.fr>
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