<?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>George&#039;s weblog &#187; sql</title>
	<atom:link href="http://www.helyar.net/tag/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.helyar.net</link>
	<description>From the desktop of George Helyar</description>
	<lastBuildDate>Thu, 26 Aug 2010 14:27:45 +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>Moving comments in WordPress</title>
		<link>http://www.helyar.net/2010/moving-comments-in-wordpress/</link>
		<comments>http://www.helyar.net/2010/moving-comments-in-wordpress/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 15:03:02 +0000</pubDate>
		<dc:creator>George Helyar</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.helyar.net/?p=440</guid>
		<description><![CDATA[In MySQL, first move the comment: UPDATE wp_comments SET comment_post_ID = P_TO_ID WHERE comment_ID = C_ID; P_TO_ID is the ID of the post you are moving it to. C_ID is the ID of the comment you are moving. You can find both of these IDs easily from the dashboard. Then correct the comment counts for [...]]]></description>
			<content:encoded><![CDATA[<p>In MySQL, first move the comment:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;color: black;"><span style="color: #993333; font-weight: bold;color: blue;">UPDATE</span> wp_comments <span style="color: #993333; font-weight: bold;color: blue;">SET</span> comment_post_ID <span style="color: #66cc66;color: black;">=</span> P_TO_ID <span style="color: #993333; font-weight: bold;color: blue;">WHERE</span> comment_ID <span style="color: #66cc66;color: black;">=</span> C_ID;</pre></div></div>

<p>P_TO_ID is the ID of the post you are moving it to. C_ID is the ID of the comment you are moving. You can find both of these IDs easily from the dashboard.</p>
<p>Then correct the comment counts for the posts:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;color: black;"><span style="color: #993333; font-weight: bold;color: blue;">UPDATE</span> wp_posts <span style="color: #993333; font-weight: bold;color: blue;">SET</span> comment_count <span style="color: #66cc66;color: black;">=</span> <span style="color: #66cc66;color: black;">&#40;</span><span style="color: #993333; font-weight: bold;color: blue;">SELECT</span> count<span style="color: #66cc66;color: black;">&#40;</span><span style="color: #66cc66;color: black;">*</span><span style="color: #66cc66;color: black;">&#41;</span> <span style="color: #993333; font-weight: bold;color: blue;">FROM</span> wp_comments <span style="color: #993333; font-weight: bold;color: blue;">WHERE</span> comment_post_id <span style="color: #66cc66;color: black;">=</span> id <span style="color: #993333; font-weight: bold;color: blue;">AND</span> comment_approved <span style="color: #66cc66;color: black;">=</span> <span style="color: #cc66cc;color: maroon;">1</span><span style="color: #66cc66;color: black;">&#41;</span>
<span style="color: #993333; font-weight: bold;color: blue;">WHERE</span> comment_count !<span style="color: #66cc66;color: black;">=</span> <span style="color: #66cc66;color: black;">&#40;</span><span style="color: #993333; font-weight: bold;color: blue;">SELECT</span> count<span style="color: #66cc66;color: black;">&#40;</span><span style="color: #66cc66;color: black;">*</span><span style="color: #66cc66;color: black;">&#41;</span> <span style="color: #993333; font-weight: bold;color: blue;">FROM</span> wp_comments <span style="color: #993333; font-weight: bold;color: blue;">WHERE</span> comment_post_id <span style="color: #66cc66;color: black;">=</span> id <span style="color: #993333; font-weight: bold;color: blue;">AND</span> comment_approved <span style="color: #66cc66;color: black;">=</span> <span style="color: #cc66cc;color: maroon;">1</span><span style="color: #66cc66;color: black;">&#41;</span>;</pre></div></div>

<p>The second line in this query is not strictly necessary but it lets you know how many posts were affected.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.helyar.net/2010/moving-comments-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
