kitenski
kitenski

Reputation: 639

Stripping strings from a MySQL field?

Is it possible to run some SQL to change the contents of a field?

My field looks like this

..//uploaded_images/1284058574.jpg

and I want it to simply be

1284058574.jpg

all the records that I wish to change will start with

..//uploaded_images/

Upvotes: 0

Views: 50

Answers (1)

rivenate247
rivenate247

Reputation: 2101

if it's already in the database you could do a find and replace?

update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, '..//uploaded_images/', '(REPLACE TEXT LEAVE EMPTY)');

you may or may not have to character escape the slashes, I'm not sure on that one

Upvotes: 3

Related Questions