Re: [GENERAL] JOIN exclusion problem

Поиск
Список
Период
Сортировка
От Chris Bitmead
Тема Re: [GENERAL] JOIN exclusion problem
Дата
Msg-id 377B5C1D.50C2F68F@tech.com.au
обсуждение исходный текст
Ответ на JOIN exclusion problem  (Anja Speerforck <anja@damn.com>)
Список pgsql-general
The problem is you've got two different result sets you need here. For
example, what would you expect to find in the k.name1 column if
k.kunden_nr is blank or null? The database doesn't know, and it can't
process the query without an answer.

You either need to break it into two separate queries or else make it
into a UNION. If it's a UNION you will need to specify explicity what to
put into k.name when joining with agenturen. I'm guessing that you want
it blank in such a case.


Anja Speerforck wrote:
>
> Thank you both for your replies.  Unfortunately, the AND solution doesn't
> work since individuals who have a value for ap.kunden_nr are not likely to
> have one for ap.agentur_nr -- they are two fairly distinct groups.  When I
> insert AND, the results are blank.
>
> Any other suggestions?
>
> At 16:23 01.07.99 +1000, you wrote:
> >Try using AND instead of OR.
> >
>
> >> SELECT apartner_nr, ap.anrede, ap.vorname, ap.nachname, ap.telefon, ap.fax,
> >> ap.email, ap.kunden_nr, k.name1, ap.agentur_nr, ag.name1
> >> FROM ansprechpartner ap, kunden k, agenturen ag
> >> WHERE ap.kunden_nr = k.kunden_nr OR ap.agentur_nr = ag.agentur_nr
> >> ORDER BY nachname"
>
> > SELECT apartner_nr, ap.anrede, ap.vorname, ap.nachname, ap.telefon, ap.fax,
> > ap.email, ap.kunden_nr, k.name1, ap.agentur_nr, ag.name1
> > FROM ansprechpartner ap, kunden k, agenturen ag
> > WHERE ap.kunden_nr = k.kunden_nr OR ap.agentur_nr = ag.agentur_nr
>                                    ^^
> You might wanna try an AND there.
>
> > ORDER BY nachname"

--
Chris Bitmead
mailto:chris@tech.com.au
http://www.techphoto.org - Photography News, Stuff that Matters

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

Предыдущее
От: "Bryan White"
Дата:
Сообщение: alter table add column is broken in 6.5
Следующее
От: "Colin Price (EML)"
Дата:
Сообщение: RE: [GENERAL] 6.4.2 and 6.5 date usertype difference