Search for entries starting with a non-letter?
am 26.01.2006 23:54:29 von news
We're trying to make a search form, and are wanting to create links for
all the letters a person can click on and will bring up all entries
that start with that letter.
That part is easy:
.... WHERE field LIKE '$letter%'
But we'd like to also have one a person can click on for numbers and
punctuation.
Is there a built-in mySQL querey component where you can search for
entries in a column that start with a non-letter?
Thanks for any feedback!
-Liam
Re: Search for entries starting with a non-letter?
am 27.01.2006 00:53:27 von Bill Karwin
wrote in message
news:1138316069.489700.138060@g44g2000cwa.googlegroups.com.. .
> Is there a built-in mySQL querey component where you can search for
> entries in a column that start with a non-letter?
I'd use the regular expression matching predicates implemented in MySQL.
For example,
.... WHERE someColumn NOT RLIKE '^[[:upper:]]'
See RLIKE in this page:
http://dev.mysql.com/doc/refman/5.0/en/pattern-matching.html
and reference for regular expression syntax in MySQL in this page:
http://dev.mysql.com/doc/refman/5.0/en/regexp.html
Regards,
Bill K.
Re: Search for entries starting with a non-letter?
am 27.01.2006 15:04:52 von news
Bill Karwin wrote:
> wrote in message
> news:1138316069.489700.138060@g44g2000cwa.googlegroups.com.. .
> > Is there a built-in mySQL querey component where you can search for
> > entries in a column that start with a non-letter?
>
> I'd use the regular expression matching predicates implemented in MySQL.
>
> For example,
> ... WHERE someColumn NOT RLIKE '^[[:upper:]]'
>
Ah! I had no idea you could do that in mySQL. almost like using a Perl
regex.
And I see, you can use REGEX in mySQL as well. =)
Thanks for the clue-by-four!
-Liam