PDA

View Full Version : MySQL trim



pucca
October 9th, 2006, 08:01 AM
Hi there

I would like to select a string in a field in my database..

Ex. The field is called test. In 'test' theres a string called 'West Coast'.

But I want to select it, taking the space out, and convert it to lower case. Is this possible. I've managed to trim it, and make it lower case, but is it possible to take out the space in the middle?


"Select id, lower(trim(test)) from provinces WHERE id = " . $id;

thanx, in advance!

bwh2
October 9th, 2006, 02:07 PM
Select id, replace(lower(test),' ','') from provinces WHERE id = 1;^there's no inner trim, so you have to use replace.

pbrollwitme
October 9th, 2006, 08:32 PM
I'm assuming you're using php...could be wrong.



$var = mysql_query("SELECT id FROM provinces WHERE id = '1'");
$var = strtolower($var);
$var = ereg_replace(" ","",$var);