Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I've seen another post about this exact thing but it's 1-1/2 years old so I thought I'd make my own...besides, the other post did not help me. What I am trying to do is pretty straight-forward.

To be on the safe side, I tried a simple UPDATE statement on a different table, which was successful. So, here's my problem:

mysql> UPDATE bugs_fulltext SET short_desc =
REPLACE(short_desc,'I don\'t know why my previous comment means.',
'I don\'t know what my previous comment means.') WHERE bug_id=452;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

I'm not using wildcards nor am I using a LIKE statement. I am telling it which record to update. Why isn't my text changed?

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

Look carefully at the query's output

Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

The expression Rows matched is based on WHERE bug_id=452;. That matched.

When you executed it, the change evidently failed because the short_desc column didn't change because short_desc does not equal 'I don\'t know why my previous comment means.'

To verify that run this:

SELECT REPLACE(short_desc,'I don\'t know why my previous comment means.',
'I don\'t know what my previous comment means.') replace_result
FROM bugs_fulltext WHERE bug_id=452;

If you getback the old value, then the old value was not in the row to begin with.

You should just directly update it (overwrite it):

UPDATE bugs_fulltext
SET short_desc = 'I don\'t know what my previous comment means.'
WHERE bug_id=452;
share|improve this answer
    
Hi, @Rolando. First, I can't do a simple update because the text within short_desc is much longer than is being shown. I'm simply trying to replace "why" with "what". Running your query, I get back the current contents of that field. I ran my query on a different column and this time I got: Rows matched: 1 Changed: 1 Warnings: 0 so I think it's user error. The column I thought had that text apparently didn't. Thanks for leading me down the right path and for your time. –  harperville Oct 9 '13 at 12:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.