From: | Carlos Mennens <carlos(dot)mennens(at)gmail(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Two Tables That Share Data? |
Date: | 2012-02-09 15:33:11 |
Message-ID: | CAAQLLO7VfoEtqgzJOE5bmGA5ePon=uZBakOU=zTHkCfk6yCY8g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Wed, Feb 8, 2012 at 4:06 PM, Philip Couling <phil(at)pedal(dot)me(dot)uk> wrote:
> You should keep the data types the same. SERIAL is in fact INTEGER so dept
> should be INTEGER.
OK I have my 'employees.dept' field type set to INTEGER but I'm still
trying to understand how I can perform a SQL statement that will allow
me to query the 'employees' table and visibly see employees.manager =
'Phill Collins' rather than it's assigned numerical INTEGER. Below are
both tables described:
Table "public.managers"
Column | Type | Modifiers
--------+-----------------------+-------------------------------------------------------
id | integer | not null default
nextval('managers_id_seq'::regclass)
name | character varying(50) | not null
email | character varying(50) | not null
dept | integer |
salary | numeric(8,2) | not null
hire | date | not null
Indexes:
"managers_pkey" PRIMARY KEY, btree (id)
"managers_email_key" UNIQUE CONSTRAINT, btree (email)
Table "public.employees"
Column | Type | Modifiers
---------+-----------------------+--------------------------------------------------------
id | integer | not null default
nextval('employees_id_seq'::regclass)
fname | character varying(50) | not null
lname | character varying(50) | not null
email | character varying(50) | not null
dept | integer |
manager | integer |
salary | numeric(8,2) | not null
hire | date | not null
Indexes:
"employees_pkey" PRIMARY KEY, btree (id)
"employees_email_key" UNIQUE CONSTRAINT, btree (email)
Is there a way I can query the employees table and have the SQL
statement resolve the INTEGER value from 'employees.manager' to
display the data in 'managers.name'?
From | Date | Subject | |
---|---|---|---|
Next Message | Oliveiros d'Azevedo Cristina | 2012-02-09 15:37:40 | Re: Conditional expresion in query |
Previous Message | JORGE MALDONADO | 2012-02-09 15:25:08 | Conditional expresion in query |