[pgsql-jp: 29432] Re: ターゲット部分のサブクエリについて

SUGIMURA Takashi 杉村 貴士 sugimura @ infoscience.co.jp
2003年 3月 17日 (月) 12:59:53 JST


杉村です。

> 現在 PostgreSQL 7.3.1 PHP4 を使用しているのですが、
> select *,(sub query1),(sub query2),(sub query3) from table1;
> とした場合
> サブクエリーの部分がすべて ?column? になってしまい
> pg_fetch_result() でカラム名を使用してのデータ取得が出来ません。
> 

一般的な SQL の知識だとは思いますが、なにかドキュメントは見ましたか。
PostgreSQL はオンラインのヘルプがすぐに出てきてわかりやすいです。

% psql hoge
Welcome to psql, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

hoge=# \h select
Command:     SELECT
Description: retrieve rows from a table or view
Syntax:
SELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]
    * | expression [ AS output_name ] [, ...]
    [ FROM from_item [, ...] ]
    [ WHERE condition ]
    [ GROUP BY expression [, ...] ]
    [ HAVING condition [, ...] ]
    [ { UNION | INTERSECT | EXCEPT } [ ALL ] select ]
    [ ORDER BY expression [ ASC | DESC | USING operator ] [, ...] ]
    [ FOR UPDATE [ OF tablename [, ...] ] ]
    [ LIMIT { count | ALL } ]
    [ OFFSET start ]

where from_item can be:

[ ONLY ] table_name [ * ]
    [ [ AS ] alias [ ( column_alias_list ) ] ]
|
( select )
    [ AS ] alias [ ( column_alias_list ) ]
|
from_item [ NATURAL ] join_type from_item
    [ ON join_condition | USING ( join_column_list ) ]

---
インフォサイエンス株式会社 プロダクト開発チーム
杉村 貴士 <sugimura @ infoscience.co.jp>
TEL: 03-5427-3509(直通), 03-5427-3500(代表) FAX: 03-5427-3530



pgsql-jp メーリングリストの案内