Re: SQL Question

Поиск
Список
Период
Сортировка
От Mo Holkar
Тема Re: SQL Question
Дата
Msg-id 5.1.0.14.2.20011111120039.009fda50@pop.ntlworld.com
обсуждение исходный текст
Ответ на SQL Question  (Brian <Brrrian@Excite.com>)
Ответы XML & Postgresql  (Joe Moraca <jmoraca@home.com>)
Список pgsql-novice
At 18:26 10/11/01, you wrote:
>A SQL Question...
>
>Bear with me... I'm kinda new here.
>
>I am trying to query table1, selecting records that do NOT have a relation
>in a subset from table3 that is related to table2.
>
>
>Example:
>
>table1(Trick table)
>  1_id,trickName,trickDescription
>
>table2(Magician table)
>  2_id,lastName,firstName
>
>table3(Trick-Magician-Knows table)
>  2_id,1_id
>
>if I choose some magician I want a list of tricks he/she DOES-NOT know.


Interesting question! I'm no SQL expert either... I would use something like:

SELECT one_id FROM table1 EXCEPT SELECT one_id FROM table3 WHERE
table3.two_id = table2.two_id AND table2.lastName = '<name of magician to
test for>';

which does generate the correct results, but there are probably more
elegant ways of doing it.

best,

Mo



Mo Holkar
Digital Mind Games -- log on to take over
mo.holkar@digitalmindgames.com
http://www.digitalmindgames.com


В списке pgsql-novice по дате отправления:

Предыдущее
От: "Brett W. McCoy"
Дата:
Сообщение: Re: Sending query to a file
Следующее
От: Henk
Дата:
Сообщение: config problems