Here's my current codes to obtain popular publish from wordpress wordpress_publish table. How do i exclude individuals in groups for example three or four?

$popularposts = "SELECT ID,post_title FROM {$wpdb->prefix}posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY comment_count DESC LIMIT 0,".$pop_posts;
$posts = $wpdb->get_results($popularposts);

after 'publish' you add (presuming the area for categorie is categorie)

and categorie not in ('3', '4')

or, if categorie is number:

and (categorie < 3 or categeorie > 4)

Dugg with the web and stackoverflow, almost reduced the problem. Still I want add

ORDER BY comment_count DESC LIMIT 0,".$pop_posts

somewhere within the following code.

$popularposts  = "SELECT * FROM $wpdb->posts 
INNER JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)  
INNER JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)  

WHERE ($wpdb->term_taxonomy.term_id <> 3  
   AND $wpdb->term_taxonomy.term_id <> 4  
   AND $wpdb->term_taxonomy.taxonomy = 'category'   
   AND $wpdb->posts.post_type = 'post'  
   AND $wpdb->posts.post_status = 'publish')";