<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Ruby on Rails Notes &#187; mysql</title> <atom:link href="http://railsnotes.com/tag/mysql/feed/" rel="self" type="application/rss+xml" /><link>http://railsnotes.com</link> <description>A code-heavy brain dump of stuff I come across working on Ruby on Rails projects including Models, ActiveRecord, Views, Controllers, RESTful rails, deployment, server stuff, etc.</description> <lastBuildDate>Sun, 29 Aug 2010 23:45:16 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.1</generator> <item><title>Find and Replace in MySQL</title><link>http://railsnotes.com/207-find-and-replace-in-mysql/</link> <comments>http://railsnotes.com/207-find-and-replace-in-mysql/#comments</comments> <pubDate>Tue, 21 Apr 2009 20:58:22 +0000</pubDate> <dc:creator>Melvin Ram</dc:creator> <category><![CDATA[Other]]></category> <category><![CDATA[database]]></category> <category><![CDATA[mysql]]></category><guid
isPermaLink="false">http://www.railsnotes.com/?p=207</guid> <description><![CDATA[Even though Rails shields us from having to resort to SQL, it&#8217;s still good to know how to do things directly. One thing I wanted to do today was find all the records that contain &#8220;blahblahblah&#8221; and replace it with &#8220;blah_dee_blah_dee_blah&#8221;. Here&#8217;s how I did it: update wp_3_posts set POST_CONTENT = replace(POST_CONTENT, 'http://www.volcanicmarketing.com/wp-content/', 'http://volcanic.sitespress.net/wp-content/uploads/'); As [...]]]></description> <content:encoded><![CDATA[<p></p><p>Even though Rails shields us from having to resort to SQL, it&#8217;s still good to know how to do things directly. One thing I wanted to do today was find all the records that contain &#8220;blahblahblah&#8221; and replace it with &#8220;blah_dee_blah_dee_blah&#8221;. Here&#8217;s how I did it:</p><pre>update wp_3_posts
set POST_CONTENT = replace(POST_CONTENT,
'http://www.volcanicmarketing.com/wp-content/',
'http://volcanic.sitespress.net/wp-content/uploads/');</pre><p>As you may or may not have guessed, this wasn&#8217;t for a Rails app. It was for my WordPress system. I had moved from single wordpress sites to a server that runs WordPress Mu. One of the changes that resulted from this was that images contained inside my posts didn&#8217;t automatically adjust. The above code fixes this. Let&#8217;s deconstruct it by looking at by looking at the structure of the command:</p><pre>update TABLE_NAME
set FIELD_NAME = replace(FIELD_NAME,
'find this string',
'replace found string with this string');</pre><p>I got the info from <a
href="http://www.mydigitallife.info/2007/04/23/how-to-find-and-replace-text-in-mysql-database-using-sql/">http://www.mydigitallife.info/2007/04/23/how-to-find-and-replace-text-in-mysql-database-using-sql/</a></p> ]]></content:encoded> <wfw:commentRss>http://railsnotes.com/207-find-and-replace-in-mysql/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (user agent is rejected)
Database Caching 6/16 queries in 0.025 seconds using disk

Served from: railsnotes.com @ 2010-09-10 05:45:36 -->