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 'S MILL%' ORDER BY sellDate DESC' at line 1SELECT count(*) total FROM history WHERE sellDate < '2024-06-26' and sellDate > '1969-11-30' and streetNumber=1201 and REPLACE(streetName,'\'','') like '%LAMEY'S MILL%' ORDER BY sellDate DESC