Stump of a Muffin

TRIM and MySQL

Working on a wireless iPhone application right now.  With such limited ‘real estate’ for viewing on wireless devices I’ve decided to trim off the 3 zeros.

I want $575,000 to show as 575.  At first I didn’t think this would be a big deal.  PHP has the nifty little substr() function and I was pretty sure MySQL did as well.

PHP:  substr( @string , 0 , -3 )

MySQL:  SELECT LEFT( @string , CHAR_LENGTH( @string ) – 3 )

Comments are closed.