SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    Canada
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Delete trailing space.

    Hey,

    I have a huge database of CD Entries and some of the titles have a trailing space at the end of them.

    For example:
    Greatest_Hits_
    (pretend that _ is a space)

    I only want to remove the space at the end of the entrie, not the ones in the middle. So for this reason the replace function wont work for me. The space is messing up a lot of queries as the browser doesnt recognize them..

    Is there an easy way to do this?

  2. #2
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Try executing the following query on your table:

    Code:
    UPDATE your_table SET greatest_hits = RTRIM(greatest_hits)
    Let me know if I have misunderstood you, or if you need more help.

    Yours, Erik.
    ERIK RIKLUND :: Yes, I've been gone quite a while.

  3. #3
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    Canada
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    I want to be able to run this on my entire CDArtist column in my table. If I run that query it will trim some entries that dont have spaces on the end right?

    80% of the entries are inputted correctly, and the rest have a space of two at the end.

    I need something like : if RTRIM('CDArtist')==" " .. I know you cant do this in MySql, but there has to be something similar.. right?

  4. #4
    SitePoint Guru MikeBigg's Avatar
    Join Date
    Jun 2004
    Location
    Reading, UK
    Posts
    970
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    RTRIM will just remove "white space", ie spaces, and will leave characters in place.

    Try it on a couple of rows or on a table used for testing.

    Mike

  5. #5
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    Canada
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HMMM,

    But it will not delete the spaces between words?

    example:
    GREATEST HITS

    Wont it delete the whitespace between Greates and Hits? I am testing it out, so I guess ill see

  6. #6
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Quote Originally Posted by tdob
    But it will not delete the spaces between words?
    No, it will only delete trailing spaces (meaning: spaces at the end of the string).

    Yours, Erik.
    ERIK RIKLUND :: Yes, I've been gone quite a while.


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
  •