SELECT COUNT(DISTINCT x.id) AS cnt_rtas, x.page_comment_counter FROM (SELECT DISTINCT ecr.encuesta_id, c.id, p.page_comment_counter FROM comentarios c INNER JOIN encuestas_contenido_respuestas_votos ecrv ON c.flujo_cid = ecrv.flujo_id AND c.ip = ecrv.ip INNER JOIN encuestas_contenido_respuestas ecr ON ecr.id = ecrv.respuesta_id INNER JOIN pages p ON p.page_id = c.single_id WHERE c.seccion = 'articulos' AND c.activo = 1 AND c.spam = 0 AND p.ID = 12606 AND ecr.encuesta_id IN () ORDER BY c.timestamp DESC) AS x GROUP BY x.encuesta_id HAVING x.page_comment_counter - cnt_rtas > 9 AND cnt_rtas > 4
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 ') ORDER BY c.timestamp DESC) AS x GROUP BY x.encuesta_id HAVING x.page_comment_c' at line 1