query result error No: 1064 Msg: 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 'rows FROM animals tbl1 WHERE tbl1.tagnumber IS NOT NULL AND (tb...' at line 1 SQL: SELECT COUNT(1) as rows FROM animals tbl1 WHERE tbl1.tagnumber IS NOT NULL AND (tbl1.sold = 0 OR tbl1.sold IS NULL) AND tbl1.categoryid = '4'