From: Richard Broersma Jr <rabroersma@yahoo.com>
To: Koen Bok <koen@madebysofa.com>
To: pgsql-sql@postgresql.org
Subject: Re: Simple Query?
Date: Tue, 11 Sep 2007 14:59:37 -0700 (PDT)
Message-ID: <7012.26158.qm@web31806.mail.mud.yahoo.com> (raw)
In-Reply-To: <2C0EA394-5AC8-4FC8-99F3-5FAEE9720360@madebysofa.com>
--- Koen Bok <koen@madebysofa.com> wrote:
> I am doing some optimization on our search, but I need some advise...
>
> table: item
>
> id name
> --------------------------------------
> 1 iPod
> 2 Zune
> 3 Walkman
>
> table: search_item
>
> id_search id_item
> --------------------------------------
> 1 1
> 1 2
> 1 3
> 2 2
> 2 3
> 3 1
> 3 3
>
>
> Now what I want to have is the items that match with id_search 1 and
> 2 and 3. Therefore I use the following SQL query.
SELECT id_search
FROM Search_item
GROUP BY id_search
HAVING Count( * ) = 3
AND Max( id_item ) = 3
AND Min( id_item ) = 1;
Regards,
Richard Broersma Jr.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: rabroersma@yahoo.com, koen@madebysofa.com
Subject: Re: Simple Query?
In-Reply-To: <7012.26158.qm@web31806.mail.mud.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox