Last active
December 27, 2015 10:39
-
-
Save workmaster2n/7313045 to your computer and use it in GitHub Desktop.
different updates
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 tracked_points SET worker_id = worker_tags.worker_id | |
FROM tags LEFT JOIN worker_tags ON tags.id = worker_tags.tag_id | |
WHERE (tags.frequency = tracked_points.frequency OR worker_tags.id IS NULL) | |
AND tracked_points.worker_id_checked_at IS NULL |
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
SELECT tracked_points.id, tracked_points.worker_id, worker_tags.worker_id FROM tracked_points | |
INNER JOIN tags ON tags.frequency = tracked_points.frequency | |
LEFT JOIN worker_tags ON worker_tags.tag_id = tags.id | |
WHERE tracked_points.worker_id IS NULL | |
AND (tags.frequency = tracked_points.frequency OR worker_tags.id IS NULL) | |
ORDER BY recorded_at DESC | |
LIMIT 100 |
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 tracked_points SET worker_id = worker_tags.worker_id | |
FROM tags | |
LEFT JOIN worker_tags ON worker_tags.tag_id = tags.id | |
WHERE tracked_points.worker_id IS NULL | |
AND tags.frequency = tracked_points.frequency |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment