From: | harrold(at)sage(dot)che(dot)pitt(dot)edu |
---|---|
To: | James Hall <James(dot)Hall(at)RadioShack(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Wildcard queries? |
Date: | 2001-08-15 16:12:53 |
Message-ID: | Pine.LNX.4.21.0108151205590.6191-100000@sage.che.pitt.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Tamara D. Blum | 2001-08-15 16:40:57 | Error installing postgresql 7.1.2 |
Previous Message | Tamara D. Blum | 2001-08-15 15:58:55 | Error installing postgresql 7.1.2 |