www.webdeveloper.com
Results 1 to 3 of 3

Thread: Word search/replace on entire DB

  1. #1
    Join Date
    Sep 2009
    Posts
    146

    Word search/replace on entire DB

    I have a DB with 15+ tables in it and I need to replace a brand name (one word no spaces) in all the tables with a different name. Iím a little rough around the edgesí with my SQL statements, any experts out there that can save me a few hours?

    Thanks,
    -aPeg

  2. #2
    Join Date
    Jan 2007
    Location
    Wisconsin
    Posts
    2,120
    For both MySQL and MSSQL, I assume you're looking for something like ...

    update tablename set col=replace(col, "old_brand", "new_brand");
    MySQL: http://dev.mysql.com/doc/refman/5.0/...nction_replace
    TSQL (MS SQL SERVER): http://msdn.microsoft.com/en-US/libr...v=SQL.90).aspx

    Is that what you need?
    Jon Wire

    thepointless.com | rounded corner generator

    I agree with Apple. Flash is just terrible.

    Use CODE tags!

  3. #3
    Join Date
    Sep 2009
    Posts
    146
    Thats exactly what i need.

    for anyone reading this with the same problem, use:
    Code:
    SHOW COLUMNS FROM '.$dbtable
    to grab all the columns in your table, then loop through using svidgen's command.

    Thanks svidgen,
    -aPeg
    Last edited by apeg; 06-04-2010 at 02:42 PM.

Thread Information

Users Browsing this Thread

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

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