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