SELECT COUNT(DISTINCT(id)) AS nb_total_images
  FROM galerie_images
    INNER JOIN galerie_image_category AS ic ON id = ic.image_id
  WHERE  AND  category_id NOT IN (1,51,50)
;
[mysql error 1064] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND  category_id NOT IN (1,51,50)' at line 4