pattern search

Started by kttalmost 24 years ago5 messagesgeneral
Jump to latest
#1ktt
kestutis98@yahoo.com

hello,

is it possible to make a search
for a pattern in PostgreSQL database,
using database functions only?
Or should I use PHP for that
purpose?

thank you for any advice,

ktt

__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

#2Joel Burton
joel@joelburton.com
In reply to: ktt (#1)
Re: pattern search

-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org]On Behalf Of ktt
Sent: Thursday, May 23, 2002 11:06 AM
To: pgsql-general@postgresql.org
Subject: [GENERAL] pattern search

hello,

is it possible to make a search
for a pattern in PostgreSQL database,
using database functions only?
Or should I use PHP for that
purpose?

PG supports standard SQL LIKE syntax, as well as full regular expression
syntax. See the section in the document on string functions and pattern
matching for information.

- J

Joel BURTON | joel@joelburton.com | joelburton.com | aim: wjoelburton
Knowledge Management & Technology Consultant

#3Darren Ferguson
darren@crystalballinc.com
In reply to: ktt (#1)
Re: pattern search

If you mean text pattern matching then it has regex capabilities

*~ i believe without checkiong the manual i m not sure.

Alternatiely you could also look at the like operater but regex is
probably what you want

HTH

Darren Ferguson

On Thu, 23 May 2002, ktt wrote:

Show quoted text

hello,

is it possible to make a search
for a pattern in PostgreSQL database,
using database functions only?
Or should I use PHP for that
purpose?

thank you for any advice,

ktt

__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

#4Jeff Eckermann
jeff_eckermann@yahoo.com
In reply to: ktt (#1)
Re: pattern search

You can do it with LIKE; PostgreSQL also supports
Regular Expression searches. Check out:

http://www.postgresql.org/idocs/index.php?functions-matching.html

--- ktt <kestutis98@yahoo.com> wrote:

hello,

is it possible to make a search
for a pattern in PostgreSQL database,
using database functions only?
Or should I use PHP for that
purpose?

thank you for any advice,

ktt

__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

---------------------------(end of
broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

#5scott.marlowe
scott.marlowe@ihs.com
In reply to: ktt (#1)
Re: pattern search

Yes, you can.

What you do is something like this:

$nugget = "smith";
$res = pg_exec($conn,"select * from table where lower(field) like
'%$nugget%'");
print implode(":",pg_fetch_array($res,0,PGSQL_ASSOC));

For large datasets, there are some issues with performance that can be
addressed by indexing or using the included full text index system
included in the postgresql-7.x.x/contrib/fulltextindex directory.

It's far better to do the search in postgresql than to suck all the data
into php and try to sort through it.

On Thu, 23 May 2002, ktt wrote:

Show quoted text

hello,

is it possible to make a search
for a pattern in PostgreSQL database,
using database functions only?
Or should I use PHP for that
purpose?