[pgsql-jp: 37527] Re: JOIN 方法

Tomoo Nomura nomurat @ tmo.co.jp
2006年 9月 11日 (月) 07:54:46 JST


select table21.name, table22.name from table1, table2 as table21, table2
as table22 where table1.item1=table21.id and table1.item2=table22.id ;

ですか?

野村




WataruIkeda wrote:
> 池田と申します。
> お時間が許せば、お知恵をお貸し下さい。
> 以下のような2つのテーブルがあります。
>
> やりたいことは Table1 の2つのカラムそれぞれに格納している値を id として
> 持つ Table2 の name 値を取得することです。できれば1度の select で行いた
> いと考えています。
>
> join では難しく苦戦しております。愚問で申し訳ありません。
> PostgreSQL 7.4.10です。宜しくお願いします。
>
>
> [Table1]
> item1|item2
> -----+------
> 1    |2
>
> [Table2]
> id   |name
> -----+------
> 1    |apple
> 2    |orange
>
> [期待値]
> item1|item2
> -----+------
> apple|orange
>
>
>
>   


-- 
****** Nomura Technical Management Office Ltd. *****************
 Tomoo Nomura      nomura @ tmo.co.jp       http://www.tmo.co.jp/ 
    Phone: +81-78-797-0240 Fax: +81-78-797-0241
 Worldwide Airline Timetable 'Flight Planner'
 European Electronic Timetable 'HAFAS'         ValueFax Support
****************************************************************




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