[pgsql-jp: 28682] Re: 複数レコードの条件検索

趙俊来 cho @ neproit.com
2003年 1月 15日 (水) 14:57:53 JST


趙と申します。

「group by」を利用して、

select user_id 
from (
	select user_id, count(*) as cnt 
	from mytable
	where 
		(title = 'A' and value = '2') or
		(title = 'B' and value = '1') or
		(title = 'C' and value = '1') or
		(title = 'D' and value = '1') 
	group by user_id
) temp
where cnt = 4;

こんな感じでしょうか。

__________________
趙 俊来(チョウ ジュンレ)
Email: <cho @ neproit.nospam.com>
MSNgr: <jounlai @ hotmail.com>
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄




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