Skip to content

Instantly share code, notes, and snippets.

@cyrilchampier
Created January 28, 2015 12:55
Show Gist options
  • Save cyrilchampier/7986cbb016ee8e48c53f to your computer and use it in GitHub Desktop.
Save cyrilchampier/7986cbb016ee8e48c53f to your computer and use it in GitHub Desktop.
UPDATE users u
SET u.default_model3d_configuration = REPLACE(u.default_model3d_configuration, 'is_fit_to_view_computed: false', 'is_fit_to_view_computed: true')
WHERE EXISTS (
SELECT *
FROM (
SELECT m.owner_id, MAX(m.updated_at) updated_at
FROM model3ds m
GROUP BY m.owner_id
) AS owner_last_model
INNER JOIN model3ds m ON m.owner_id = owner_last_model.owner_id AND m.updated_at = owner_last_model.updated_at
INNER JOIN mod_display_configurations mdc ON m.id = mdc.model3d_id
WHERE mdc.is_fit_to_view_computed = true
AND m.owner_id = u.id
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment