Re: Syntax for wildcard selection

From: John Clark Naldoza y Lopez <njclark(at)ntsp(dot)nec(dot)co(dot)jp>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Scott Holmes <sholmes(at)pacificnet(dot)net>, PG-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Syntax for wildcard selection
Date: 2001-08-16 01:26:10
Message-ID: 3B7B2131.7FF2F3FE@ntsp.nec.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bruce Momjian wrote:
>
> > This question just came up from a user use to our Informix application. They
> > tried to do a wildcard search, thus "where field_name LIKE 'AB%VN'". The
> > trailing values (after the %) are not recognized correctly. With Informix
> > 4GL, we wrote "where field_name MATCHES 'AB*VN'". This finds any combination
> > of values with 'AB' as the first two characters, and 'VN' as the last two,
> > with any number of characters in between - including blanks. How is this
> > accomplished with PostgreSQL? Are we limited to wildcard searches as "where
> > field_name LIKE 'AB%'"?
>
> Trailing stuff should always be recognized, and I am sure PostgreSQL
> does this.
>

Perhaps regular expression may help you out...

WHERE field_name ~ '^AB' AND field_name ~ 'VN$'

You should also only process those that have greater than four
characters in the field_name...;-)

Hope that helps...;-)

Cheers,

John Clark
--
/) John Clark Naldoza y Lopez (\
/ ) Software Design Engineer III ( \
_( (_ _ Web-Application Development _) )_
(((\ \> /_> Cable Modem Network Management System <_\ </ /)))
(\\\\ \_/ / NEC Telecom Software Phils., Inc. \ \_/ ////)
\ / \ /
\ _/ phone: (+63 32) 233-9142 loc. 3113 \_ /
/ / cellphone: (+63 919) 399-4742 \ \
/ / email: njclark(at)ntsp(dot)nec(dot)co(dot)jp \ \

"Intelligence is the ability to avoid doing work, yet getting the work
done"
--Linus Torvalds

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jason Turner 2001-08-16 02:42:15 Re: Syntax for wildcard selection
Previous Message Scott Holmes 2001-08-16 00:11:28 Re: Syntax for wildcard selection