bookmark.php Favorites Bookmark this page to Reddit Share this page on Twitter Bookmark this page to Delicious Bookmark this page to Facebook Bookmark this page to StumbleUpon More bookmarks

Shopping


Community




Discuss about databases and SQL related topics including MySQL, PostgreSQL, Oracle and SQL Server.
 March 28 2010

phpMyAdmin search and replace


kwok

Exclusive member

User Avatar


Reputation:
Medals: 1 
March 2010 (1)

 Joined: January 2010
 Country: United States (us)
 Location: WWW
 Posts: 144
Member Blog: View Blog (0)
Invitations sent: 0
Successful invitations: 0

F$: 2,465,871.00
Bank: 1,000.00
Instant Play Lottery Ticket Username - Black Post Count +100 Beer Gold Medal Silver Medal Gold Star Silver Star




Here is a great tip that can save you hours of work. Sometimes you have messed up characters in your database - wrong character encodings - or you want to strip out some text in a certain table's field. In phpMyAdmin, open up the SQL dialog and use the following code (change tablename and tablefield to your name and field values):

Code: Select all
UPDATE tablename SET tablefield = replace(tablefield, "findstring", "replacestring");


You can also tack on a WHERE statement, if you like.
Last edited by kwok on March 28 2010, edited 1 time in total.
 

 March 28 2010

Conditional phpMyAdmin search and replace


kwok

Exclusive member

User Avatar


Reputation:
Medals: 1 
March 2010 (1)

 Joined: January 2010
 Country: United States (us)
 Location: WWW
 Posts: 144
Member Blog: View Blog (0)
Invitations sent: 0
Successful invitations: 0

F$: 2,465,871.00
Bank: 1,000.00
Instant Play Lottery Ticket Username - Black Post Count +100 Beer Gold Medal Silver Medal Gold Star Silver Star




In addition to the above find and replace in phpMyAdmin,
kwok wrote:
Code: Select all
UPDATE tablename SET tablefield = replace(tablefield, "findstring", "replacestring");

you can also create a conditional search and replace like this:
Code: Select all
UPDATE `tablename` SET `tablefield` = '0' WHERE `anotherfield` = 'condition' AND `tablefield` = '1'
 

Related Threads

Last Post By


Basic SQL commands in phpMyAdmin: Search, Insert, Update, ..


  Started by kwok on March 29 2010
kwok
on April 28 2010 Go to last post
   Replies: 6    Views: 168

Copy a MySQL table with phpMyAdmin


  Started by kwok on March 29 2010
kwok
on March 29 2010 Go to last post
   Replies: 0    Views: 73
Display Options (This thread contains 2 posts) Currently Active Users Viewing This Thread
Posted Time Order By Sort By

No registered users and 0 guests

 
 Posting Rules

You cannot post new threads in this forum
You cannot reply to threads in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum





cron