Chuck "Pup" Payne wrote:
> 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


One of two things to do:

When you're inserting the data, figure out the first letter and store 
that as a separate column ("letter" perhaps)

Second, probably easier to implement in your case with existing data,
is to use LIKE.

$sql = "select * from datatable where last_name like '$letter%'";

The % is a wildcard symbol, so if $letter is "a" then a last name
of "adams", "aames", "aston", etc. would all match.

I know there's someway to have mysql do a string manipulation to compare 
just part of a column's data with something, so you could do something 
similar to a 'substr' in PHP - but it's late and I can't remember off 
the top of my head.


Hope that helps...


--------------------------
Michael Kimsal
http://www.phphelpdesk.com
Taking the ? out of <?php
734-480-9961



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to