![]() |
![]() |
![]() |
||||
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. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
. . .
Industry Role:
Join Date: Apr 2007
Location: NY
Posts: 13,724
|
![]() 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? |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
MOBILE PORN: IMOBILEPORN
Join Date: Jan 2004
Location: Tinseltown NL
Posts: 16,502
|
update yourtable set field_name = 'newvalue'
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
. . .
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? |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 | |
Confirmed User
Join Date: Jul 2004
Location: The Beach
Posts: 4,626
|
Quote:
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 |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
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 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
. . .
Industry Role:
Join Date: Apr 2007
Location: NY
Posts: 13,724
|
thanks polle, that will get me started
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Confirmed User
Join Date: Apr 2002
Location: /root/
Posts: 4,997
|
The sky is Yellow.
|
![]() |
![]() ![]() ![]() ![]() ![]() |