Ted
Ted

Reputation: 4166

MySQL: fix data inserted inside quotes in DB

I need to fix some (bad) inserted data in DB, I had data inserted with single qoutes like: ('love')

I want to move this to (love), without effect on something like (we're),

info table (structure)

id     text
1     'love'
2     'man'
3     we're..
4     John
5     'Sarah'

I want to fix "info" table to be:

info table (structure)

id     text
1      love
2      man
3      we're..
4      John
5      Sarah

I can select this data using:

select * from info where text like "'%'"

thanks,

Upvotes: 0

Views: 50

Answers (2)

Nitin Alapati
Nitin Alapati

Reputation: 79

You can use this statement to update all the rows of the table.

update Table_Name
set ColumnName= REPLACE(ColumnName,'''','')
where ColumnName LIKE ('''%''')

Upvotes: 0

Jens
Jens

Reputation: 69450

try this untested query:

update info set text = replace(text,"'","") where text like "'%'"

Upvotes: 3

Related Questions