<?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>The Blog of an Egyptian Songbird &#187; MySQL</title>
	<atom:link href="http://blog.twinklesprings.com/category/programming/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.twinklesprings.com</link>
	<description>A translation of my mind's short circuits.</description>
	<lastBuildDate>Thu, 05 Mar 2009 20:57:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MySQL equivalent of str_replace &#124; Search and Replace</title>
		<link>http://blog.twinklesprings.com/2008/03/31/mysql-equivalent-of-str_replace-search-and-replace/</link>
		<comments>http://blog.twinklesprings.com/2008/03/31/mysql-equivalent-of-str_replace-search-and-replace/#comments</comments>
		<pubDate>Mon, 31 Mar 2008 13:04:22 +0000</pubDate>
		<dc:creator>Shadi Almosri</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[ask vince]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[str_replace]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://blog.twinklesprings.com/2008/03/31/mysql-equivalent-of-str_replace-search-and-replace/</guid>
		<description><![CDATA[A great little time saving tip when doing database management, or any sort of migrations within domains that might require you to modify a certain part of a string in a MySQL column.
The issue:
You have an online store that stores all the products in a MySQL table called &#8216;products&#8217;, your images are hard coded links [...]]]></description>
			<content:encoded><![CDATA[<p>A great little time saving tip when doing database management, or any sort of migrations within domains that might require you to modify a certain part of a string in a MySQL column.</p>
<p><strong>The issue</strong>:</p>
<p>You have an online store that stores all the products in a MySQL table called &#8216;products&#8217;, your images are hard coded links to something similar to <em>http://www.mydomain.com/image/example_image.jpg</em> but you have now moved to &#8216;newdomain.com&#8217; so you need all your images to look like: <em>http://www.newdomain.com/image/example_image.jpg</em>.</p>
<p>Rather than having to create a PHP script for this, you can use the rather &#8220;cool&#8221; SQL statement:</p>
<p><code>UPDATE `table` SET `column`=replace(`column`,`old_text`, `new_text`);</code></p>
<p>So for our example above we would carry out:</p>
<p><code>UPDATE `table` SET `descriptions`=replace(`descriptions`,`mydomain.com`, `newdomain.com`);</code></p>
<p>NOTE: The code above will change ALL mentions of &#8216;mydomain.com&#8217; to &#8216;newdomain.com&#8217;, you might require it to be more precise in which case you just need to fine tune the &#8220;old_text&#8221; and the &#8220;new_text&#8221; sections to look and change what you require.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.twinklesprings.com/2008/03/31/mysql-equivalent-of-str_replace-search-and-replace/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
