Created
March 9, 2017 01:26
-
-
Save aslakknutsen/bc393aec69d4a9e9aac009abff1ae77b to your computer and use it in GitHub Desktop.
Order of execution in a single SQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE work_items set execution_order = ( | |
SELECT | |
( | |
( | |
SELECT execution_order | |
FROM work_items | |
WHERE id = '12262' | |
) | |
+ | |
( | |
SELECT execution_order | |
FROM work_items | |
WHERE execution_order < ( | |
SELECT execution_order | |
FROM work_items | |
WHERE id = '12938' | |
) | |
ORDER BY execution_order DESC | |
LIMIT 1 | |
) | |
) | |
/2 | |
) | |
WHERE id = 12938; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment