making mass edits in SQL database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • d-null
    . . .
    • Apr 2007
    • 13724

    #1

    making mass edits in SQL database

    anyone have any pointers for me in doing some database editing?

    I would like to change one field in all of the entries in my database... is there a search and replace utility around, or can you recommend a method?

    __________________

    Looking for a custom TUBE SCRIPT that supports massive traffic, load balancing, billing support, and h264 encoding? Hit up Konrad!
    Looking for designs for your websites or custom tubesite design? Hit up Zuzana Designs
    Check out the #1 WordPress SEO Plugin: CyberSEO Suite
  • Bro Media - BANNED FOR LIFE
    MOBILE PORN: IMOBILEPORN
    • Jan 2004
    • 16502

    #2
    update yourtable set field_name = 'newvalue'

    Comment

    • d-null
      . . .
      • Apr 2007
      • 13724

      #3
      thanks for the reply, but I didn't explain my question very well

      what I want to do is in a big sql database, I would like to mass edit replace many records all at once

      say for example I wanted to change every occurence of the word "Blue Elephant" to read instead "Yellow Elephant", but only in one category

      how can I do a search and replace in my entire mysql with one easy move?

      __________________

      Looking for a custom TUBE SCRIPT that supports massive traffic, load balancing, billing support, and h264 encoding? Hit up Konrad!
      Looking for designs for your websites or custom tubesite design? Hit up Zuzana Designs
      Check out the #1 WordPress SEO Plugin: CyberSEO Suite

      Comment

      • polle54
        Confirmed User
        • Jul 2004
        • 4626

        #4
        Originally posted by jetjet
        thanks for the reply, but I didn't explain my question very well

        what I want to do is in a big sql database, I would like to mass edit replace many records all at once

        say for example I wanted to change every occurence of the word "Blue Elephant" to read instead "Yellow Elephant", but only in one category

        how can I do a search and replace in my entire mysql with one easy move?
        Okay let's say that the text "Blue Elephant" is in a field called animal_name.

        You tables is named animals.

        go into phpmyadmin or something like that

        write:

        update animals set animal_name = "Yellow Elephant" where animal_name LIKE "Blue Elephant"

        Now this is if you can replace the whole name.

        if you need to change something in the middle of a text it will look something like this:

        tablename stil animals.
        Fieldname now animal_text

        the content og the animal_text could be something like "this is once again a blue elephant walking around"

        your statement should look something like this:

        update animals set animal_text = REPLACE(animal_text, "Blue", "Yellow") where animal_text LIKE '%Blue%'

        This statement should replace all occurrences of the word Blue. adding the where clause with the LIKE statement is actually just for performance, can be left out if performance is not an issue here.

        It's out of the top of my head so it might not be working 100% but then read up on using replace() in a sql update.
        Last edited by polle54; 11-29-2007, 01:32 AM.
        ICQ# 143561781

        Comment

        • polle54
          Confirmed User
          • Jul 2004
          • 4626

          #5
          short answer I think would be:

          UPDATE yourtablename SET columnname = REPLACE(columnname, 'Text to Replace', 'Text to Replace with')
          ICQ# 143561781

          Comment

          • d-null
            . . .
            • Apr 2007
            • 13724

            #6
            thanks polle, that will get me started

            __________________

            Looking for a custom TUBE SCRIPT that supports massive traffic, load balancing, billing support, and h264 encoding? Hit up Konrad!
            Looking for designs for your websites or custom tubesite design? Hit up Zuzana Designs
            Check out the #1 WordPress SEO Plugin: CyberSEO Suite

            Comment

            • darksoul
              Confirmed User
              • Apr 2002
              • 4997

              #7
              Originally posted by polle54
              update animals set animal_text = REPLACE(animal_text, "Blue", "Yellow") where animal_text LIKE '%Blue%'
              The sky is Yellow.
              1337 5y54|)m1n: 157717888
              BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
              Cambooth

              Comment

              Working...