Re: SQL Question - Mailing list pgsql-novice

From Brian
Subject Re: SQL Question
Date
Msg-id 3.0.5.32.20011112105422.0094d7b0@pop.we.mediaone.net
Whole thread Raw
In response to Re:  (John Burski <John.Burski@911ep.com>)
List pgsql-novice
This was correctly answered on another list by Steve Miskovitz.
I am posting it here for those of you who have been working this. There is more in depth info about the sql technique
heuses in his solution at the SQL Tutor:  

http://w3.one.net/~jhoffman/sqltut.htm#More_Subqueries

It is essentially a NOT EXISTS in a (subquery)

Here is the answer which I copied and pasted making the appropriate table name and field changes into my real world
application,(though magic could be cool.) 
---------------------------
from: Steve Miskovitz <steve@collegepublisher.com>
---------------------------
Subject: RE: SQL Question

here is a straight forward way :

SELECT TR.1_id
FROM Trick TR
WHERE NOT EXISTS (
    SELECT *
    FROM Trick-Magician-Knows TMK
    WHERE TMK.1_id = TR.1_id
        AND TMK.2_id = ?)

So it selects all tricks that DO NOT have a corresponding entry in the Trick-Magician-Knows table for a given magician.
Switch the ? with 2_id of the magician. 



pgsql-novice by date:

Previous
From: Joe Moraca
Date:
Subject: XML & Postgresql
Next
From: "amp "
Date:
Subject: Re: