I saw the below query in algoexpert where they say they can update the job id based on the previous query. I have seen an update query with a select clause inside it or the merge clause that inserts or updates depending on a match
Is there some SQL syntax that lets you do the below. Please can you point me to links to read up on this?
BEGIN TRANSACTION;
SELECT * FROM jobs_table WHERE status = 'QUEUED' ORDER BY created_at ASC LIMIT 1;
// if there's none, we ROLLBACK;
UPDATE jobs_table SET status = 'RUNNING' WHERE id = id from previous query;
COMMIT;
where id in (...)UPDATE jobs_table SET ... WHERE EXISTS(...)instead.