You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AND purpose = 3' at line 160SELECT COUNT(id) as count FROM estate WHERE status = 1 AND category = 9 AND subcategory = AND purpose = 3