Re: Syntax for wildcard selection

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Scott Holmes <sholmes(at)pacificnet(dot)net>
Cc: PG-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Syntax for wildcard selection
Date: 2001-08-15 23:45:31
Message-ID: 20010816094531.A16062@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Aug 15, 2001 at 04:06:16PM -0700, Scott Holmes 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%'"?

The only thing I can think of is that you are using char() fields and the
like is getting confused by the trailing spaces. Certainly putting wildcards
anywhere in the string works fine.

What is the data type of your column? text and varchar() wouldn't suffer
from the above problem.
--
Martijn van Oosterhout <kleptog(at)svana(dot)org>
http://svana.org/kleptog/
> It would be nice if someone came up with a certification system that
> actually separated those who can barely regurgitate what they crammed over
> the last few weeks from those who command secret ninja networking powers.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2001-08-15 23:54:30 Re: Syntax for wildcard selection
Previous Message Jason Turner 2001-08-15 23:36:14 Re: Syntax for wildcard selection