Re: Wildcard queries? - Mailing list pgsql-novice

From harrold@sage.che.pitt.edu
Subject Re: Wildcard queries?
Date
Msg-id Pine.LNX.4.21.0108151205590.6191-100000@sage.che.pitt.edu
Whole thread Raw
In response to Wildcard queries?  (James Hall <James.Hall@RadioShack.com>)
List pgsql-novice
Sometime in August James Hall assaulted keyboard and produced...

|Hello,
|
|I am trying to do a wildcard search on a table, for example:
|
|I have a table - info - that has a text field - business_name.
|One value in that field is Demo Inc.
|
|My question is can I execute a query that would search that field for demo*?
|Something to the effect of "SELECT * FROM info WHERE business_name LIKE
|'demo*';
|and return Demo Inc.?
|


if you used the ~* operator (or maybe it's *~) that will do a case
insensitive search. if you are looking for words starting with demo you
might want to try  ' demo'. so it would be something like this:

select * from info where business_name ~* ' demo';

this would miss any fields that had new lines that start with demo. i dont
know if there is a character that represents the beginning of a line. in
most applications (in unix that is) the ^ character matches the beginning
of the line and the $ character matches the end.

assuming that postgres understands this a query like:

select * from info where business_name ~* '^demo';

might match any line starting with demo. to get all newwords starting with
demo (case insensitive)

select * from info where business_name ~* '^demo' OR business_name ~* '
demo';

you will have to check the manual about identifiers of the beginning and
end of lines.

--
john
There is no operating system but linux and linus is its kernel maintainer.





pgsql-novice by date:

Previous
From: Jason Earl
Date:
Subject: Re: How to Make aggragate Function? Standard Deviation?
Next
From: John Burski
Date:
Subject: Opaque data type