Hi there, having problems with the following:

Поиск
Список
Период
Сортировка
От Jens Philipsen
Тема Hi there, having problems with the following:
Дата
Msg-id sabb595d.032@gyldendal.dk
обсуждение исходный текст
Ответы Re: Hi there, having problems with the following:  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Список pgsql-sql
Hi there, having problems with the following:
On Postgresql (on Linux)
I have 3 tables:

1)employee
firstname
lastname
initials

2)has_title
initials
title

3)has_trade
initials
trade



Now, what I would like is to get a list of all employees with all their titles and trades - employees can have zero or
severaltitles/trades.
 

For testing purposes I made a version in MS Access, in which this works:
(SELECT medarbejder.initialer, fornavn, efternavn, telefon, titel, null AS fag
FROM medarbejder, har_titel, har_fag
where medarbejder.initialer=har_titel.initialer)
UNION
(SELECT medarbejder.initialer, fornavn, efternavn, telefon, null AS titel, fag
FROM medarbejder, har_fag, har_titel
WHERE medarbejder.initialer=har_fag.initialer)

But in Postgresql no such luck:

SELECT medarbejder.initialer, fornavn, efternavn, telefon, titel as titel, null AS fag
FROM medarbejder, har_titel, har_fag 
WHERE medarbejder.initialer=har_titel.initialer  
UNION  
SELECT medarbejder.initialer, fornavn, efternavn, telefon, null as titel, fag AS fag
FROM medarbejder, har_fag, har_titel 
WHERE medarbejder.initialer=har_fag.initialer

Only produces an error:
"unable to transform varchar to unknown
Each UNION | EXCEPT | INTERSECT clause must have compatible target"

Any suggestions?
Thanx in advance
Jens




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

Предыдущее
От: "datactrl"
Дата:
Сообщение: About Raise Exception
Следующее
От: "pgsql-sql"
Дата:
Сообщение: Re(2): trigger output to a file