Re: selecting first character from a MySQL table

From: Date: Thu, 05 Jun 2003 02:10:34 +0000
Subject: Re: selecting first character from a MySQL table
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-150291@lists.php.net to get a copy of this message
In article <5.2.1.1.0.20030603154536.00bc4ef0@mail.nwconx.net>, immortal@nwconx.net says... > Hi, > > First, let me say many thanks to those who responded to my cron tab > question - it's working well now. And now for my next trick ;) > > I'm looking for more of an opinion here. I'm doing an alphabetical listing > of members for this site, I've done a general query of my MySQL table to > select all the members, but I was wondering if PHP could select only the > first character and display only those members who's name begins with an > 'A', 'B', 'C', etc? > > I know I can do a selective query in MySQL using the LEFT command - but > that would mean doing a query for each letter of the alphabet - is there a > better way, or shall I start querying away? I guess it would be possible to do this with 'DISTINCT' - something like SELECT DISTINCT LEFT(1,1,field) FROM ..... Yes I know the syntax is probably wrong but I can't be hanged checking the docs :-) Cheers -- Quod subigo farinam $email =~ s/oz$/au/o;

« previous php.general (#150291) next »