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

Помогите написать выборку.

From: Peter Teslenko <smartchecker(at)gmail(dot)com>
To: pgsql-ru-general(at)postgresql(dot)org
Subject: Помогите написать выборку.
Date: 2011-05-19 14:30:17
Message-ID: 4DD52979.1040802@gmail.com (view raw or flat)
Thread:
Lists: pgsql-ru-general
Приветствую.

Есть несколько таблиц. Мне нужно написать выборку чтобы вместо 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)



-- 
Peter Teslenko
Jabber: peter(at)jabber(dot)mcicb(dot)ru

Responses

pgsql-ru-general by date

Next:From: Dmitriy IgrishinDate: 2011-05-19 15:31:28
Subject: Re: [pgsql-ru-general] Помогите написа
Previous:From: Andrey SudnikDate: 2011-04-10 18:06:43
Subject: Re: Pg documentation in russian

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