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 >= '2018-11-16' ) ORDER BY date_exe ASC, ID_prog ' at line 1