views:

23

answers:

1

my table have set of records around 50,

in the table i have column called USERNAME , but some of username leading and trailing have the white space ,

so am not getting exact order result because of white space,

So tell me how to use the trim in SELECT query ,

Thanks

+2  A: 

You can use TRIM in the ORDER BY:

ORDER BY TRIM(username)

...but this will only trim excess space on the left and right side of the text, not in between.

Using TRIM in the SELECT is as easy as:

SELECT TRIM(username) AS username
  FROM your_table
OMG Ponies