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 'ON as.slot_id = as1.slot_id WHERE a.is_active = 1 AND ( ad.exp_date >=...' at line 5