Posts Tagged ‘sql’

Stop saying SEQUEL

Saturday, July 2nd, 2011

SQL is not the same thing as SEQUEL. If you’re a grumpy old DBA, stuck in your ways, who actually used SEQUEL back in the 1970s, that’s fine. For all the new kids just getting into SQL, it’s pronounced es-que-el, not sequel. When you call it sequel, you sound like just as much of an idiot as someone who says lynuks. It’s annoying.

The “SQL” pronunciation is actually defined in the original 1986 specification for SQL and confirmed by common DBMS such as MySQL.

Moving comments in WordPress

Sunday, February 7th, 2010

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 the posts:

UPDATE wp_posts SET comment_count = (SELECT COUNT(*) FROM wp_comments WHERE comment_post_id = id AND comment_approved = 1)
WHERE comment_count != (SELECT COUNT(*) FROM wp_comments WHERE comment_post_id = id AND comment_approved = 1);

The second line in this query is not strictly necessary but it lets you know how many posts were affected.