Skip site navigation (1) Skip section navigation (2)

Re: [pgsql-ru-general] Помогите написа

From: Dmitriy Igrishin <dmitigr(at)gmail(dot)com>
To: Peter Teslenko <smartchecker(at)gmail(dot)com>
Cc: pgsql-ru-general(at)postgresql(dot)org
Subject: Re: [pgsql-ru-general] Помогите написа
Date: 2011-05-19 15:31:28
Message-ID: BANLkTik7gig+zeCunqJ2AHvnGz56aPdgeQ@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-ru-general
Приветствую Пётр,

19 мая 2011 г. 18:30 пользователь Peter Teslenko
<smartchecker(at)gmail(dot)com>написал:

> Приветствую.
>
> Есть несколько таблиц. Мне нужно написать выборку чтобы вместо
> request_type_id и прочих _id подставлялись
> текстовые значения из соотв. таблиц. Один JOIN я ещё написать могу, а с
> остальными теряюсь.
>
> drupal6=# \d journal_of_requests
>                                         Table "public.journal_of_requests"
>      Column       |            Type             |
>   Modifiers
>
> -------------------+-----------------------------+-------------------------------------------------------------------
>  rid               | integer                     | not null default
> nextval('journal_of_requests_rid_seq'::regclass)
>  request_date      | timestamp without time zone | not null default now()
>  request_type_id   | integer                     | default 0
>  request_object_id | integer                     | default 0
>  request_org       | character varying(255)      | default ''::character
> varying
>  request_person    | character varying(255)      | default ''::character
> varying
>  request_phone     | character varying(255)      | default ''::character
> varying
>  request_point     | character varying(255)      | default ''::character
> varying
>  request_state_id  | integer                     | default 0
>  request_comment   | character varying(255)      | default ''::character
> varying
>  request_executive | character varying(255)      |
> Indexes:
>    "journal_of_requests_pkey" PRIMARY KEY, btree (rid)
>    "journal_of_requests_rid_idx" btree (rid)
> Check constraints:
>    "journal_of_requests_request_object_id_check" CHECK (request_object_id
> >= 0)
>    "journal_of_requests_request_state_id_check" CHECK (request_state_id >=
> 0)
>    "journal_of_requests_request_type_id_check" CHECK (request_type_id >= 0)
>    "journal_of_requests_rid_check" CHECK (rid >= 0)
>
>
> drupal6=# \d request_object
>                                  Table "public.request_object"
>  Column  |          Type          |                          Modifiers
>
> ----------+------------------------+--------------------------------------------------------------
>  oid      | integer                | not null default
> nextval('request_object_oid_seq'::regclass)
>  obj_name | character varying(255) | not null
> Indexes:
>    "request_object_pkey" PRIMARY KEY, btree (oid)
>    "request_object_oid_idx" btree (oid)
> Check constraints:
>    "request_object_oid_check" CHECK (oid >= 0)
>
>
> drupal6=# \d request_state
>                                   Table "public.request_state"
>   Column   |          Type          |                          Modifiers
>
> ------------+------------------------+-------------------------------------------------------------
>  sid        | integer                | not null default
> nextval('request_state_sid_seq'::regclass)
>  state_name | character varying(255) | not null
> Indexes:
>    "request_state_pkey" PRIMARY KEY, btree (sid)
>    "request_state_sid_idx" btree (sid)
> Check constraints:
>    "request_state_sid_check" CHECK (sid >= 0)
>
>
> drupal6=# \d request_type
>                                  Table "public.request_type"
>  Column |          Type          |                          Modifiers
>
> --------+------------------------+-------------------------------------------------------------
>  rtid   | integer                | not null default
> nextval('request_type_rtid_seq'::regclass)
>  type   | character varying(255) | not null
> Indexes:
>    "request_type_pkey" PRIMARY KEY, btree (rtid)
>    "request_type_rtid_idx" btree (rtid)
> Check constraints:
>    "request_type_rtid_check" CHECK (rtid >= 0)
>
SELECT request_type.type, request_state.state_name,  request_object.obj_name
  FROM journal_of_requests
  JOIN request_type ON request_type_id = rtid
  JOIN request_object ON request_object_id = oid
  JOIN request_state ON request_state_id = sid;

>
>
>
> --
> Peter Teslenko
> Jabber: peter(at)jabber(dot)mcicb(dot)ru
>
> --
> Sent via pgsql-ru-general mailing list (pgsql-ru-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-ru-general
>



-- 
// Dmitriy.

In response to

pgsql-ru-general by date

Next:From: Serguei MokhovDate: 2011-06-09 14:10:39
Subject: Re: Установка под win7x64
Previous:From: Peter TeslenkoDate: 2011-05-19 14:30:17
Subject: Помогите написать выборку.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group