SELECT `wp3_posts` . `ID` FROM `wp3_posts` INNER JOIN `wp3_postmeta` ON ( `wp3_posts` . `ID` = `wp3_postmeta` . `post_id` ) WHERE ? = ? AND `wp3_posts` . `ID` NOT IN (?) AND ( ( `wp3_postmeta` . `meta_key` = ? AND CAST ( `wp3_postmeta` . `meta_value` AS CHARACTER ) = ? ) ) AND `wp3_posts` . `post_type` IN (...) AND ( ( `wp3_posts` . `post_status` = ? ) ) GROUP BY `wp3_posts` . `ID` ORDER BY `wp3_posts` . `post_date` DESC 