Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 27th, 2004, 04:50 PM
Authorized User
 
Join Date: Mar 2004
Location: , , Latvia.
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default Replace text fragments

Hello!

Is there a way to replace specific text fragment (string) with another one in all fields of a table by an SQL query?

Thanks!
Janis

Reply With Quote
  #2 (permalink)  
Old October 29th, 2004, 02:43 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Do you want that to be done for a column on all rows or for all columns in all rows? Can you explain that in detail?

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #3 (permalink)  
Old October 29th, 2004, 08:21 PM
Authorized User
 
Join Date: Mar 2004
Location: , , Latvia.
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by happygv
 Do you want that to be done for a column on all rows or for all columns in all rows? Can you explain that in detail?
For one (text type) column on all rows.

Janis

Reply With Quote
  #4 (permalink)  
Old October 30th, 2004, 02:24 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Check the MySql documentation for, if that supports REPLACE() function, if so you can do that easily. Else, will have to look for other way round.

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #5 (permalink)  
Old November 1st, 2004, 09:23 AM
Authorized User
 
Join Date: Mar 2004
Location: , , Latvia.
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks! It really worked, when I found that function.

Before that I searched for "replace" in the documentation, but found that replace is an operation like insert, only it replaces the rows in case of a duplicate key or something like that. And I didn't even search more to find out that there is such a function replace(). :)

So, I successfully managed to replace text with this kind of query:

update tableName
set fieldName=replace(fieldName,"oldString","newString")

Thanks,
Janis

Reply With Quote
  #6 (permalink)  
Old November 1st, 2004, 04:43 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, Glad that it worked. I was sure about Replace function's existence in MS Sql Server, though I haven't really used that in MySql/need didn't arise yet. That's why I suggested to check if MySql supports that function.

Cheers!

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search and Replace a text in XML file AyatKh XML 17 May 23rd, 2012 10:05 PM
replace text without using regex mrame XSLT 7 July 28th, 2008 10:12 AM
Text Replace with XSLT pendyalap XSLT 13 October 1st, 2006 06:51 PM
Replace textboxes or textareas with some text amit_bhatia Beginning PHP 1 December 7th, 2004 11:32 AM
Button to replace close window text Burton HTML Code Clinic 12 November 6th, 2003 12:27 PM



All times are GMT -4. The time now is 12:36 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.