Re: Selecting first letter from MySQL entry
| From: | Dragos Roua | Date: | Wed, 09 Aug 2000 14:55:25 +0000 |
| Subject: | Re: Selecting first letter from MySQL entry | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-10935@lists.php.net to get a copy of this message | ||
> Hello everyone,
>
> I need to be able to select the first letter in a MySQL field. the field
> name is first (for first name). There are peoples names listed there. I
> have links set up to look like this:
> index.php?letter=A
> index.php?letter=B
> index.php?letter=C
> and so on
> So when a user clicks on index.php?letter=C it would need to display all of
> the first names that begin with C.
>
> How do I accomplish this?
>
> Regards,
"select first_name, name from my_table where substring(name, 1, 1) = 'letter'";
Untested but I guess it should work. You could always take a look at the string
functions built into mysql.
HTH,
--
Dragos Roua
Mirabilis Media,
http://www.portal.ro http://www.net-info.ro
http://www.analyser.ro http://www.adserver.ro
http://www.culinar.ro http://www.cartipostale.ro