Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 11-29-2007, 02:31 AM   #1
d-null
. . .
 
d-null's Avatar
 
Industry Role:
Join Date: Apr 2007
Location: NY
Posts: 13,724
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?
d-null is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-29-2007, 02:35 AM   #2
Bro Media - BANNED FOR LIFE
MOBILE PORN: IMOBILEPORN
 
Join Date: Jan 2004
Location: Tinseltown NL
Posts: 16,502
update yourtable set field_name = 'newvalue'
Bro Media - BANNED FOR LIFE is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-29-2007, 03:08 AM   #3
d-null
. . .
 
d-null's Avatar
 
Industry Role:
Join Date: Apr 2007
Location: NY
Posts: 13,724
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?
d-null is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-29-2007, 03:31 AM   #4
polle54
Confirmed User
 
Join Date: Jul 2004
Location: The Beach
Posts: 4,626
Quote:
Originally Posted by jetjet View Post
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.
__________________
ICQ# 143561781

Last edited by polle54; 11-29-2007 at 03:32 AM..
polle54 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-29-2007, 03:34 AM   #5
polle54
Confirmed User
 
Join Date: Jul 2004
Location: The Beach
Posts: 4,626
short answer I think would be:

UPDATE yourtablename SET columnname = REPLACE(columnname, 'Text to Replace', 'Text to Replace with')
__________________
ICQ# 143561781
polle54 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-29-2007, 03:56 AM   #6
d-null
. . .
 
d-null's Avatar
 
Industry Role:
Join Date: Apr 2007
Location: NY
Posts: 13,724
thanks polle, that will get me started
d-null is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-29-2007, 04:01 AM   #7
darksoul
Confirmed User
 
darksoul's Avatar
 
Join Date: Apr 2002
Location: /root/
Posts: 4,997
Quote:
Originally Posted by polle54 View Post
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
darksoul is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.