SELECT
task.id,
task.dc,
task.provider,
task.type,
task.url,
task.cost,
task.cost_bot,
task.last_start_msec,
task.url_id,
task.remains,
task.cat
FROM
Task task
WHERE
task.status = 'active'
AND task.type = 'follow_profile'
AND task.provider = 'insta'
AND task.cat = 3
AND NOT EXISTS(
SELECT 1 FROM TaskFlow flow
WHERE
flow.url_id = task.url_id
AND flow.executor_acc_id = $acc
);