Hi chuck,

use left()

assuming your column is called "name", then something like this will do:

$letter = "a";

$get = @mysql_query("SELECT * FROM table WHERE LEFT(surname, 1) = '$letter'
ORDER BY surname ASC");

That should get out all of the fields beginning with a or A and list them
alphabetically.

Hope that's of some help.


James

"Chuck "Pup" Payne" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I want to sort by a letter in a colomn. Let say I want to sort the colomn
> last_name. I can do order by but I can do just the A's.
>
> http://www.myserver.com/mysort.php?Letter=A
>
> Like to create a link on a web "A" then sort only the last name are A.
>
> I hope that's helps. I can order by, but I can't so a sort like the
example
> above.
>
> Chuck Payne
> Magi Design and Support
>
>
> > on 3/10/02 9:42 PM, Cary at [EMAIL PROTECTED] wrote:
> >
> >> At 08:24 PM 3/10/02, Chuck \"PUP\" Payne wrote:
> >>> Hi,
> >>>
> >>> I not a newie but I am not a pro at mysql either. I want to do a query
by
> >>> letter(a, b, c..ect.). Is there a simple way to do it. I am writing in
PHP.
> >>> So can someone please so me the how.
> >>
> >>
> >> I'm not totally sure what your looking for. If you could elaborate a
little
> >> I am sure that one of us could help you out.
> >>
> >> Cary
> >>
> >>
> >>
> >
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to