Problem how to combine to two tables

From: "Torsten Willrich" <willrich(at)iese(dot)fhg(dot)de>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Problem how to combine to two tables
Date: 2002-03-27 12:23:29
Message-ID: 000b01c1d58a$342d6d40$6a866099@iese.fhg.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Ok, to explain my problem, it is the easiest way, to make an example:

let's say we have two tables:

Table1 looks like this:

Employee_ID Room
------------------------
{1,3} 201
{3} 202

And Table2 looks like this:

ID Employee
---------------
1 Torsten
2 Markus
3 Daniel

This means, that if the two tables are linked properly, that Torsten and
Daniel sit in room no. 201 and Markus in room No. 202. And linking properly
is my problem:

I want an output like this

Employee_ID Room ID Employee
{1,3} 201 1 Torsten
{1,3} 201 3 Daniel
{2} 202 2 Markus

That means, that the SELECT-statement has to be something like this:
SELECT * from Table1,Table2 where Table1.Employee_ID=Table2.ID;

But of course this doesn't work, because I can't compare an int to a set of
int :-(

Does anyone know how to do this correct?

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Andrew G. Hammond 2002-03-27 14:58:02 Re: Possible to do this in one query?
Previous Message Peter Galbavy 2002-03-27 11:32:02 Non-use of index ?