Subject Re: [firebird-support] Search strategy
Author Dimitry Sibiryakov
On 19 Apr 2004 at 8:52, Bob Murdoch wrote:

>create table keyword(
> keyword_id integer not null primary key,
> word varchar(50) not null,
> content_id integer not null foreign key);
>
>create table content(
> content_id integer not null primary key,
> article blob sub_type 1);
>
>I'm looking for advice on how to implement the 'all words' query, where an
>article from Content would be returned only if it contained all three words
>from the sample above.

I would split your query into two: one for getting article id(s)
and another for retrieving articles themselves.
The first query might look like this:

select k.content_id, count(*) from keyword k
where k.word = 'firebird' or
k.work = 'database' or
k.word = 'search'
group by k.content_id
having count(*) = 3 /* 3 is number of key words in this case */

If your keyword table includes duplicate words in the same article,
use count(distinct k.work).

SY, Dimitry Sibiryakov.