Hi, one of the fields in my MySql table has a leading and a trailing “ that I would like to remove. Is there a query that I can use to find all occurrences of “ and replace them with nothing?
Thanks.
Peter.
You could use PHP to query the DB, run [man]preg_replace[/man] to "clean up" the data, and then reupdate your table. Depending on the number of rows in your database, it may almost be easier to just manually do it... How big of a table are we talking about here?
There are 61 rows of data.... maybe I will just export it to a file, edit/replace in Excel and then upload back into MySql. It seems pretty clumbsy though and I thought that there would be some query that I could run to do this, but seems not.
well this would replace all in the string, not just trailing and ending, but if that works cool
update table set field = replace(field, '"', '')
table
field
Right, it changes the entire column values from '"whatever"' to 'field'.
Is there wild card support in MySql? Maybe this is the way...
How about:
UPDATE `table_name` SET `column_name` = TRIM(BOTH '"' FROM `column_name`)
yea i came up w/ this...
update table set field = replace(field, '"', '') where field regexp '".*"$'
oops beat, nice solution...
Hey guys, nice one, both of these worked. Thanks a lot!
Now, how do I mark a post as resolved?