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 ( (dt_start>='2020-07-04' and '2020-07-04'<=dt_end) or (dt_start>=' at line 3 SQL=SELECT * FROM #__mijoshop_sspd_rule WHERE product_id = and ( (dt_start>='2020-07-04' and '2020-07-04'<=dt_end) or (dt_start>='2020-07-04' and dt_end='0000-00-00') or (dt_start>='0000-00-00' and '2020-07-04'<=dt_end) ) ORDER BY dt_create desc LIMIT 0,1