<?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>FiddyP &#187; replace</title>
	<atom:link href="http://fiddyp.co.uk/tag/replace/feed/" rel="self" type="application/rss+xml" />
	<link>http://fiddyp.co.uk</link>
	<description>The personal blog of Andy Bailey</description>
	<lastBuildDate>Sun, 13 May 2012 15:28:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>How to do a mass text search and replace with MySQL</title>
		<link>http://fiddyp.co.uk/how-to-do-a-mass-text-search-and-replace-with-mysql/</link>
		<comments>http://fiddyp.co.uk/how-to-do-a-mass-text-search-and-replace-with-mysql/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 10:28:46 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[profit]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://fiddyp.co.uk/?p=1521</guid>
		<description><![CDATA[I noticed that all my images on the posts here weren&#8217;t showing and it was because the url to their location was still pointing at the sub blog [..]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ffiddyp.co.uk%2Fhow-to-do-a-mass-text-search-and-replace-with-mysql%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ffiddyp.co.uk%2Fhow-to-do-a-mass-text-search-and-replace-with-mysql%2F&amp;source=commentluv&amp;style=normal&amp;service=bit.ly&amp;service_api=R_259b4e5679e2c431cca1f989e158bba4&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I noticed that all my images on the posts here weren&#8217;t showing and it was because the url to their location was still pointing at the sub blog on The Comluv Network so I needed a way to edit the database to update the url to point to the files held here.</p>
<p>Easy with a REPLACE function on the wp_posts table.</p>
<p>You just need 3 things for the replace command :
<ol>
<li>The row you&#8217;re altering</li>
<li>The string you&#8217;re searching for</li>
<li>The string you&#8217;re replacing with</li>
</ol>
<p><code>UPDATE `wp_posts` SET `post_content` = REPLACE( `post_content` , "fiddyp.comluv.com/files/", "fiddyp.co.uk/wp-content/uploads/" )</code></p>
<p>It did the whole table of posts in less than a second. Sweet, now all my images are back to normal on this site.</p>
]]></content:encoded>
			<wfw:commentRss>http://fiddyp.co.uk/how-to-do-a-mass-text-search-and-replace-with-mysql/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

