use intelligence_system; SELECT * FROM main_task WHERE is_active = 1 AND next_run_time <= %s AND is_running = 0 ORDER BY next_run_time;