| From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
|---|---|
| To: | pantelis vlachos <vlachos83(at)gmail(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: find a substring on a text (data type) column |
| Date: | 2012-11-08 07:55:24 |
| Message-ID: | CAFj8pRC16-CSa3Q-fcAg4Nuf3Y03vT-tHptizJH=itYwn2W6xA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hello
2012/11/8 pantelis vlachos <vlachos83(at)gmail(dot)com>:
> I was trying to find a substring on a text (data type) column like 'cat foo
> dog ...'.
> I use the query below
> SELECT id FROM table WHERE name LIKE '% foo %';
> Sometimes the query return with nTuples=0 but there are matching rows.
> On retry, the query return with expected results. Any ideas;
isn't problem in spaces, so LIKE '% foo %' must fail when symbol is on
begin or end?
you can check ' ' || name || ' ' LIKE '% foo %'
or better - use fulltext instead
Regards
Pavel Stehule
>
> (postgres ver 9.2, libpq - C Library)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Filip Rembiałkowski | 2012-11-08 08:45:58 | Fwd: question on foreign key lock |
| Previous Message | pantelis vlachos | 2012-11-08 07:49:20 | find a substring on a text (data type) column |