Skip to content

Instantly share code, notes, and snippets.

@mewm
Created October 12, 2014 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mewm/fb6481d6a457de9c81f9 to your computer and use it in GitHub Desktop.
Save mewm/fb6481d6a457de9c81f9 to your computer and use it in GitHub Desktop.
update table_with_posts p set col_to_update = (
select
col_to_update_from
from
table_to_update_from
where
table_to_update_from.id in (<comma separated ids or select id statement)
order by rand()
limit 1
) where id in (<ids to posts you wanna update>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment