[pgsql-jp: 25623] Re: JOINの使い方!?
Yu Ooasa
you @ reset.jp
2002年 4月 19日 (金) 14:59:50 JST
Fri, 19 Apr 2002 14:34:39 +0900
Seiji Hamaguchi <makoto @ par.allnet.ne.jp> said:
>cast1 はともかくとして、cast2のcastnameを取得するには
>どうすればいいのでしょうか?
select id,name,cast1,castindex1.castname,cast2,castindex2.castname
from main
left outer join castindex as castindex1
on cast1 = castindex1.castid
left outer join castindex as castindex2
on cast2 = castindex2.castid;
id | name | cast1 | castname | cast2 | castname
----+-----------+-------+-----------+-------+-----------
1 | あの映画1 | 1 | あの俳優1 | 2 | あの俳優2
2 | あの映画2 | 3 | あの俳優3 | 4 | あの俳優4
3 | あの映画3 | 1 | あの俳優1 | 6 | あの俳優6
(3 rows)
--
Yu Ooasa E-mail: you @ dearest.net
pgsql-jp メーリングリストの案内