<?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>Tim Keller &#187; sql</title>
	<atom:link href="http://timk.co.za/tag/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://timk.co.za</link>
	<description>Web, IT, Telecoms, Development, Networks, Photography, Life.</description>
	<lastBuildDate>Sat, 10 Jul 2010 12:49:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Comparing two MySQL tables</title>
		<link>http://timk.co.za/2010/02/01/comparing-two-mysql-tables/</link>
		<comments>http://timk.co.za/2010/02/01/comparing-two-mysql-tables/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 15:05:52 +0000</pubDate>
		<dc:creator>Tim Keller</dc:creator>
				<category><![CDATA[Geek]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[Opensource]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://timk.co.za/?p=62038231</guid>
		<description><![CDATA[From time to time, I need to compare MySQL database tables and see what data has been added to the one in the time since I mysqldump&#8217;d the first one.
For example: Let&#8217;s say I have table_a as my snapshot&#8217;d table, and table_b as my newer table which has one or more new rows in it.The [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-62038234 alignright" style="margin: 0px; border:0" title="MySQL Logo" src="http://timk.co.za/wp-content/uploads/2010/02/mysql_logo.gif" alt="" width="250"  />From time to time, I need to compare MySQL database tables and see what data has been added to the one in the time since I mysqldump&#8217;d the first one.</p>
<p>For example: Let&#8217;s say I have table_a as my snapshot&#8217;d table, and table_b as my newer table which has one or more new rows in it.The query below will return all records that are in table_b, and not in table_a.</p>
<pre><code>SELECT table_b.* FROM table_b
LEFT JOIN table_a ON table_b.id = table_a.id
WHERE table_a.item_id IS NULL</code></pre>
<p>This idea can be extrapolated to comparing the tables of two different databases:</p>
<pre><code>SELECT database_b.sometable.* FROM database_b.sometable
LEFT JOIN database_a.sometable ON database_b.sometable.id = database_a.sometable.id
WHERE database_a.sometable.item_id IS NULL</code></pre>
<p>The you can take those results and use them to INSERT the missing records, should you want to do this.</p>
]]></content:encoded>
			<wfw:commentRss>http://timk.co.za/2010/02/01/comparing-two-mysql-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
