SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Jan 2007
    Posts
    967
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    having a problem with trim

    I need to get rid of white spaces at the end of a field.

    When I use "SELECT trim(field) from db"
    It is still outputting with a space at the end.

    Is it possible its some other type of hidden character?
    Is there a way to strip non alphanumeric characters.

    Ideas..

    Thanks
    E

  2. #2
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,245
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by eruna View Post
    When I use "SELECT trim(field) from db"
    It is still outputting with a space at the end.
    please find one example where there is still some white space, then run this:
    Code:
    SELECT HEX(field)
      FROM daTable
     WHERE ... -- pick the row with the bad field
    you will see that it isn't a blank/space but probably some other white space character like a carriage return or line feed
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Guru
    Join Date
    Jan 2007
    Posts
    967
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    please find one example where there is still some white space, then run this:
    Code:
    SELECT HEX(field)
      FROM daTable
     WHERE ... -- pick the row with the bad field
    you will see that it isn't a blank/space but probably some other white space character like a carriage return or line feed
    Thanks for the tip. It turned out to be a non breaking space.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •