select * from where active=1 and (enddate='0000-00-00' or enddate>'2018-10-18') and (startdate='0000-00-00' or startdate<='2018-10-18') order by startdate desc
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 'where active=1 and (enddate='0000-00-00' or enddate>'2018-10-18') and (startdate' at line 1