Jump to content

Usuwanie początkowych i końcowych znaków nowych linii z wpisów w bazie

Bartosz Wójcik

Recommended Posts

Jakby ktoś potrzebował, bo właśnie korygowałem błędnie zaimportowane wpisy w bazie, które zawierały na początkowy znaki nowej linii.

Usuwanie z początku stringa:

UPDATE `tabela` SET `kolumna` = REPLACE(TRIM(LEADING ' ' FROM `kolumna`), 
                                        TRIM(LEADING '\r' FROM `kolumna`), 
                                        TRIM(LEADING '\n' FROM `kolumna`))

Usuwanie z końca stringa:

UPDATE `tabela` SET `kolumna` = REPLACE(TRIM(TRAILING ' ' FROM `kolumna`), 
                                        TRIM(TRAILING '\r' FROM `kolumna`), 
                                        TRIM(TRAILING '\n' FROM `kolumna`))
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...