Subject | Re: Finding Unique Records with Union |
---|---|
Author | devincayce |
Post date | 2006-10-04T13:39:24Z |
Thanks for responding. I thought of that too, but my real query is more complex, 6 unions
with a total of four fields searched so I thought that might get to complex. It seemed like
there could be a simpler way like "do a UNION, but ignore the ranking field" or something
that might be faster to do post searching, but I'll give your idea a shot.
with a total of four fields searched so I thought that might get to complex. It seemed like
there could be a simpler way like "do a UNION, but ignore the ranking field" or something
that might be faster to do post searching, but I'll give your idea a shot.
--- In firebird-support@yahoogroups.com, Alexandre Benson Smith <iblist@...> wrote:
>
> devincayce wrote:
> > I am trying to create a custom search text query so I can have control over how the
ranking is
> > assigned and for other reasons. This is a simple example:
> >
> > SELECT DISTINCT title, 1 AS ranking WHERE title CONTAINING "Jet Ranger" UNION
> > SELECT DISTINCT title, 2 AS ranking WHERE title CONTAINING "Jet" OR title
CONTAINING
> > Ranger" ORDER BY 2
> >
> > which works. However, I get multiple versions of the same record because it will
return the
> > record titled "Jet Ranger" twice with a rank of 1 and 2.
> >
> > Is there a way to insure it only returns the "Jet Ranger" record once? Is there a way to
"hide"
> > the rank column from the UNION function when it removes duplicates? Or is there a
better
> > way to do all of this? Thanks.
> >
>
> Hi !
>
> I think there is a bunch of ways of achieving this, one simples will be:
>
> SELECT DISTINCT title, 1 AS ranking WHERE title CONTAINING 'Jet Ranger' UNION
> SELECT DISTINCT title, 2 AS ranking WHERE (title CONTAINING 'Jet' OR title CONTAINING
> 'Ranger') and (title not CONTAINING 'Jet Ranger') ORDER BY 2
>
> see you !
>
> --
> Alexandre Benson Smith
> Development
> THOR Software e Comercial Ltda
> Santo Andre - Sao Paulo - Brazil
> www.thorsoftware.com.br
>