您可以使用WP 3.1中引入的get\\u tax\\u sql()函数:
$tax_query = array(
array(
\'taxonomy\' => \'category\',
\'terms\' => array( 4, 6, 7, 9 ),
\'operator\' => \'NOT IN\'
)
);
$clauses = get_tax_sql( $tax_query, $wpdb->posts, \'ID\' );
...
"SELECT ID, post_date, post_date_gmt, comment_status, comment_count
FROM $wpdb->posts {$clauses[\'join\']}
WHERE post_status = \'publish\'
AND post_type = \'post\'
{$clauses[\'where\']}
"
...
(未测试)