Re: JOINING TWO TABLES - Mailing list pgsql-novice

From Ashish Karalkar
Subject Re: JOINING TWO TABLES
Date
Msg-id 016901c7d8ca$10c68eb0$170211ac@LIONKING.COM
Whole thread Raw
In response to Re: JOINING TWO TABLES  (Richard Broersma Jr <rabroersma@yahoo.com>)
List pgsql-novice
Even you can drop the manager table and only keep employees table containg
mangers and employees to and then self join the table.
and then query


select e.employee_name , e1.employee_name as manager_name from
employee e, employee e1
where e.manager_id=e1.employee_id

With Regards
Ashish


----- Original Message -----
From: "Richard Broersma Jr" <rabroersma@yahoo.com>
To: <vamseelist@gmail.com>; <pgsql-novice@postgresql.org>
Sent: Monday, August 06, 2007 9:57 PM
Subject: Re: [NOVICE] JOINING TWO TABLES


>
> --- vamseelist@gmail.com wrote:
>> I mean d,e got 1 and 2 in mgr table.
>> d,e got 4,5 in new table.
>>
>> I would like to replace 1 1 2 with 4 4 5.
>>
>> I would like to modify above table as
>
> I would modify your manager and employees tables to look like:
>
>
> CREATE TABLE Employees (
>  emp_id SERIAL PRIMARY KEY,
>  name text,
>  mgr_id INTEGER);
>
> CREATE TABLE Managers (
>  mgr_id INTEGER PRIMARY KEY REFERENCES Employees( emp_id ));
>
>   ALTER TABLE Employees
> ADD CONSTRAINT managers_of_employees
>   FOREIGN KEY ( mgr_id )
>    REFERENCES Managers( mgr_id );
>
> Regards,
> Richard Broersma Jr.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>               http://archives.postgresql.org


pgsql-novice by date:

Previous
From: Luca Ferrari
Date:
Subject: buffer page lock vs tuple lock (?)
Next
From: "Angelica Garcia"
Date:
Subject: Arrow keys do not work while using psql