mysql:11630
From: "T.Sasaki" <"T.Sasaki" <papasan2000@xxxxxxxxxx>>
Date: 27 Jun 2005 09:52:28 +0900
Subject: [mysql 11630] Re: 3つのテーブルのjoin
佐々木です。 MySQL 4.0.x 且つ、MyISAM テーブル、という条件で どうしても実現したいなら、複数のSQLになります。 select get_lock( 'lock1', 20 ); create table temp1 select gid, count(*) as uid_cnt from usr group by gid; create table temp2 select gid, sum( inum ) as inum_sum from item group by gid; select g.gid, g.gname, t1.uid_cnt, t2.inum_sum from grp g, temp1 t1, temp2 t2 where t1.gid = g.gid and t2.gid = g.gid order by g.gid; drop table temp1, temp2; select release_lock( 'lock1' ); +-----+---------+---------+----------+ | gid | gname | uid_cnt | inum_cnt | +-----+---------+---------+----------+ | 1 | チームA | 2 | 24 | | 2 | チームB | 1 | 3 | +-----+---------+---------+----------+ get_lock, release_lock については下記を参照してください。 http://dev.mysql.com/doc/mysql/ja/miscellaneous-functions.html
11624 2005-06-25 01:22 [MAO <mao@xxxxxxxxxx>] 3つのテーブルのjoin -> 11630 2005-06-27 09:52 ┗["T.Sasaki" <papasan2]