Solved

Replacing a word in a MySQL table

Posted on 2011-02-17
3
288 Views
Last Modified: 2012-06-27
I've got a table in a MySQL database and I need to replace a word in one particular column. I'm using the code below and it didn't work. What am I missing?

update [news] set [main_body] = replace([main_body],'[Colgate]','[Texaco]');
0
Comment
Question by:brucegust
  • 2
3 Comments
 
LVL 3

Expert Comment

by:thecrew
ID: 34919709
Get rid of the square brackets?
0
 
LVL 3

Accepted Solution

by:
thecrew earned 250 total points
ID: 34919779
Actually I'm certain, I don't know why I used a question mark. Remove those brackets!
:)
0
 
LVL 34

Assisted Solution

by:Beverley Portlock
Beverley Portlock earned 250 total points
ID: 34919801
Try

UPDATE news SET main_body = REPLACE( main_body, 'Colgate', 'Texaco' )

See http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace for more info
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now