Re: Two Tables That Share Data?

Поиск
Список
Период
Сортировка
От Carlos Mennens
Тема Re: Two Tables That Share Data?
Дата
Msg-id CAAQLLO7VfoEtqgzJOE5bmGA5ePon=uZBakOU=zTHkCfk6yCY8g@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Two Tables That Share Data?  (Philip Couling <phil@pedal.me.uk>)
Ответы Re: Two Tables That Share Data?  (Michael Wood <esiotrot@gmail.com>)
Список pgsql-novice
On Wed, Feb 8, 2012 at 4:06 PM, Philip Couling <phil@pedal.me.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'?

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

Предыдущее
От: JORGE MALDONADO
Дата:
Сообщение: Conditional expresion in query
Следующее
От: "Oliveiros d'Azevedo Cristina"
Дата:
Сообщение: Re: Conditional expresion in query