PDA

View Full Version : mySQL - trim leading / trailing blank space from POST table's "pagetext" column


Rik Brown
12-06-2008, 03:50 AM
I've been trying to run a mySQL query to trim leading and trailing blank spaces in the pagetext column of the posts table in order to clean up the presentation of the post data. I've been testing the following query on a single post:

UPDATE `post` SET `pagetext` = TRIM(pagetext) WHERE postid = '427517';

I don't see anything wrong with the query. However, it nukes the entire line of data for any specific post. Does anyone know what I'm doing wrong?

Thanks. -- Rik

luki
12-08-2008, 05:31 AM
Try:

UPDATE post SET pagetext = TRIM(BOTH ' ' FROM pagetext) WHERE postid = 1;

Rik Brown
12-08-2008, 06:51 AM
Try:

UPDATE post SET pagetext = TRIM(BOTH ' ' FROM pagetext) WHERE postid = 1;

Lukas:

That worked perfectly. Cleaned up thousands of pages in just a minute.

Thanks a lot! -- Rik