Re: Syntax for wildcard selection - Mailing list pgsql-general

From John Clark Naldoza y Lopez
Subject Re: Syntax for wildcard selection
Date
Msg-id 3B7B2131.7FF2F3FE@ntsp.nec.co.jp
Whole thread Raw
In response to Re: Syntax for wildcard selection  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: Syntax for wildcard selection  (Jason Turner <jasont@indigoindustrial.co.nz>)
List 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@ntsp.nec.co.jp                        \   \


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

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Syntax for wildcard selection
Next
From: Jason Turner
Date:
Subject: Re: Syntax for wildcard selection