From: | Alfonso Afonso <aafonsoc(at)gmail(dot)com> |
---|---|
To: | Rafał Pietrak <rafal(at)zorro(dot)isa-geek(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: using text search |
Date: | 2013-04-22 15:57:16 |
Message-ID: | FDCCE484-89DC-49BA-B596-E9834616010D@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi Rafal
Maybe you should think or consider to have normalized database to do this kind of select.
I mean that if the keyword is a key you could add a column to table orders and have it ordered and indexed without having to reevaluate the query every time.
About your question, if you are searching a text inside another text you could obtain bizarre results and consume a lot of resources, but my approximation to your problem would be doing direct select instead of join select (in fact it is almost the same, but more readable on this cases), like:
select o.* from orders as o, keywords as k
where o.info like ('%' || k.phrase || '%')
Hope help you.
Bye for now
El 22/04/2013, a las 14:15, Rafał Pietrak <rafal(at)zorro(dot)isa-geek(dot)com> escribió:
> ... or not (I'm not quite sure)
>
> Hello,
>
> I have the following tables:
>
> CREATE TABLE orders (info text, ....);
> CREATE TABLE keywords (phrase text, .....);
>
> And I need to find all the ORDERS rows, which conain a PHRASE present in the info column ... like so:
> SELECT o.* from orders o join keywords k on (o.info ~~ '%' || k.phrase || '%');
>
> ... only this does not work, since:
> ERROR: argument of JOIN/ON must be type boolean, not type text
>
> is this possible in SQL? Or may be this a job for "ts_something()" (havent' learned to use them, yet)???
>
> -R
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
Alfonso Afonso
(personal)
From | Date | Subject | |
---|---|---|---|
Next Message | Moshe Jacobson | 2013-04-22 15:58:58 | Need solution for weekly database "snapshot" |
Previous Message | Daniel Cristian Cruz | 2013-04-22 14:06:45 | Re: Memory usage after upgrade to 9.2.4 |