Re: index search
| From: | Robert Cummings | Date: | Fri, 24 Oct 2008 02:49:12 +0000 |
| Subject: | Re: index search | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-282387@lists.php.net to get a copy of this message | ||
On Thu, 2008-10-23 at 19:30 -0700, Ryan S wrote:
> Hey all,
> Was wondering how this is done, have a bunch of links like so:
> 0-9 : a : b : c -----> till Z
>
> these will be linked to the program (so far have done this) but when the user clicks any of
> those links I want to query the DB for just the first alphabet from the field "title",
> using LIKE is not working for me because its catching alphabets from the middle of the word as well.
You're using like wrong... you want to use it with one %...
where foo like 'a%'
> Also how to do 0-9? do i have to have 10 if() conditions for that?
Maybe you could add a new field to the table and set it to the first
character of the field or 0 if it's a digit. Then you can index it and
not use "like" or multiple conditions to match digits.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP