Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: tricky SQL Question

Re: tricky SQL Question

From: Isaac Blank <izblank_at_yahoo.com>
Date: Fri, 04 Feb 2000 17:07:57 GMT
Message-ID: <389b0677.340981745@news.nanospace.com>


On Thu, 3 Feb 2000 17:42:10 -0700, "Larry Pettit" <larry.pettit_at_ps.net> wrote:

>Given the following table/columns;
>
> product_number keyword
>----------------------- ------------
> 1 bat
> 1 wood
> 1 large
> 2 bat
> 2 metal
>
>I want to do a lookup where I get a match based on the number of words
>entered. For example I know that a self join, or subquerry would work but I
>would have to add a level or table for each keyword.
>For example;
>
> select t1.product
> from product_lookup t1,
> product_lookup t2
> where t1.keyword = 'wood' and
> t2.keyword = 'bat' and
> t1.product = t2.product
>
> PRODUCT
>--------
> 1
>
>Anybody have a solution that works recursively for any number of keywords?
>
>Thanks
>
>

select product
from product_lookup
where keyword in ('wood','bat')
group by product
having count(*)=2

If you want to match for more keywords, then change the WHERE and HAVING clauses correspondingly Received on Fri Feb 04 2000 - 11:07:57 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US