Re: SQL Question

Поиск
Список
Период
Сортировка
От Brian
Тема Re: SQL Question
Дата
Msg-id 3.0.5.32.20011112105422.0094d7b0@pop.we.mediaone.net
обсуждение исходный текст
Ответ на Re:  (John Burski <John.Burski@911ep.com>)
Список 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 по дате отправления:

Предыдущее
От: Joe Moraca
Дата:
Сообщение: XML & Postgresql
Следующее
От: "amp "
Дата:
Сообщение: Re: