Search Postgresql Archives

Re: find a substring on a text (data type) column

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello

2012/11/8 pantelis vlachos <vlachos83@xxxxxxxxx>:
> 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)


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux