Re: Last Name extraction in query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2011-04-04 at 11:50 -0400, Jim Giner wrote:

> having a problem posting this message - forgive any duplication please.
> 
> Hi,
> I'm trying to use sql to extract the last name from a person's name field in
> my table.  Here's my Select:
> 
> $q = "SELECT race_winner,count(race_date) as wins,
> substr(race_winner,FIELD(' ',race_winner)) as last_name
> 
> etc.,,,
> 
> 
> 
> My result keeps coming up with a 0 for the FIELD portion I assume
> since my output shows a blank last_name.  From the docs I believe it should 
> be giving me the right-most portion of the 'race_winner' field beginning 
> where the first space char is found.
> 
> Am I not using this correctly?  Is there a better way to do this?  I'm
> trying to have my results sorted by last name and since the table was not
> built with separate first/last name fields, I'm stuck with figuring
> somethign out.
> 
> 
> 
> 
> 


Where's the PHP question in this, as what you've asked would be better
asked on a database list, as it's an SQL query.

Thanks,
Ash
http://www.ashleysheridan.co.uk



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux