pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jens Philipsen <DNJP@Gyldendal.dk>
To: pgsql-sql@postgresql.org
Subject: Hi there, having problems with the following:
Date: Fri, 23 Mar 2001 14:10:26 +0100
Message-ID: <sabb595d.032@gyldendal.dk> (raw)

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 several titles/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





view thread (2+ messages)  latest in thread

Message-ID: <sabb595d.032@gyldendal.dk>
Permalink:  ../sabb595d.032@gyldendal.dk/
Also on:    postgresql.org/message-id/sabb595d.032@gyldendal.dk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: DNJP@Gyldendal.dk
  Subject: Re: Hi there, having problems with the following:
  In-Reply-To: <sabb595d.032@gyldendal.dk>
  References: <sabb595d.032@gyldendal.dk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox