-----Message d'origine-----
De : Freshman [mailto:[EMAIL PROTECTED]
Envoyé : jeudi 30 octobre 2003 13:38
À : [EMAIL PROTECTED]
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

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org

Reply via email to