<?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>BinaryKitten&#039;s Blog &#187; update</title>
	<atom:link href="http://binarykitten.me.uk/tag/update/feed" rel="self" type="application/rss+xml" />
	<link>http://binarykitten.me.uk</link>
	<description></description>
	<lastBuildDate>Tue, 07 Sep 2010 08:02:22 +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>MySQL &#8211; Conditional Updates</title>
		<link>http://binarykitten.me.uk/dev/mysql/144-mysql-conditional-updates.html</link>
		<comments>http://binarykitten.me.uk/dev/mysql/144-mysql-conditional-updates.html#comments</comments>
		<pubDate>Sat, 07 Mar 2009 01:31:58 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://binarykitten.jkrswebsolutions.co.uk/?p=144</guid>
		<description><![CDATA[Just a quick blog post in an update related way, Recently i&#8217;ve needed to toggle multiple rows in a database from 1 value to 1 of possible 2 values dependant on the contents of a field on the row. I wasn&#8217;t sure if this was possible, so i asked in #PHPWomen IRC Channel and the [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick blog post in an update related way,</p>
<p>Recently i&#8217;ve needed to toggle multiple rows in a database from 1 value to 1 of possible 2 values dependant on the contents of a field on the row. I wasn&#8217;t sure if this was possible, so i asked in #PHPWomen IRC Channel and the general response was that of &#8220;Don&#8217;t Know&#8221;.</p>
<p>So After a backup of the table in question, i decided to try it and see. After all, the worst it could do was just not work. So I tried the following:</p>
<pre class="brush: sql">
UPDATE `tble_name` SET `field1`=IF(`field2`=&#039;arbitrary_value&#039;,1,0) WHERE `field3`=&#039;other_value&#039;
</pre>
<p>And Voila updated all the rows exactly as needed.</p>
<p>So, It is possible to update all rows in a table, limited to a group and update value based upon a field matching a certain Value.<br />
So all in all MySQL For the WIN!!!</p>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.me.uk/dev/mysql/144-mysql-conditional-updates.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
