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 = 1' at line 160SELECT COUNT(id) as count FROM estate WHERE status = 1 AND category = 6 AND subcategory = AND purpose = 1