www.webdeveloper.com
Results 1 to 8 of 8

Thread: Replace Specific Characters in mysql PHP

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Posts
    452

    Unhappy Replace Specific Characters in mysql PHP

    Hi all, I am working with a site with an old database having more than 2000 product entries... and most of the products have the article number as ASC-000-000-00

    what i want to do is to replace these article numbers with DSC-000-000-00... I dont want to edit/update every entry for that... what I want is just a simple query or 3-4 PHP statements to accomplish,,, any ideas...

  2. #2
    Join Date
    Feb 2005
    Posts
    345

  3. #3
    Join Date
    Mar 2009
    Posts
    452
    that's too funny... plz read my question again... i want to replace character(s) in mysql and records are more than 2000 ... so str_replace is useless there

  4. #4
    Join Date
    Feb 2005
    Posts
    345
    either write a php script that does the following:
    db query -> for each entry str_replace() -> update db

    or export the db data to a txt file and use the search and replace function of an editor (e.g. Notepad++) and import the data into the db again.
    free music: comatronic

  5. #5
    Join Date
    Jan 2009
    Posts
    3,346
    Maybe utilizing the built in string manipulation functions of the DB rather than some convoluted flat file hack as suggested...
    http://dev.mysql.com/doc/refman/5.0/...functions.html

  6. #6
    Join Date
    Feb 2005
    Posts
    345
    something like this?
    Code:
    update table_name set field_name = replace(field_name,'find_this','replace_with_that');
    free music: comatronic

  7. #7
    Join Date
    Jan 2009
    Posts
    3,346
    Quote Originally Posted by jogol View Post
    something like this?
    Code:
    update table_name set field_name = replace(field_name,'find_this','replace_with_that');
    That looks about right. I would test on a sample dataset before throwing production data through it just to be safe though.

  8. #8
    Join Date
    Mar 2009
    Posts
    452
    Quote Originally Posted by jogol View Post
    something like this?
    Code:
    update table_name set field_name = replace(field_name,'find_this','replace_with_that');
    Thanx man... thats what I wanted

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles