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 ( valid < 3 AND date_exe >= '2019-07-18' ) ORDER BY date_exe ASC, ID_prog ' at line 1