Created
April 15, 2014 19:11
-
-
Save srayhan/10760944 to your computer and use it in GitHub Desktop.
Update Random Rows in a Table based on a Join Condition (PostgreSQL)
This file contains hidden or 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 table1 SET table1.col1 = 'some value' WHERE id IN (SELECT table1.id FROM table1, table2 WHERE table1.table2_id = table2.id and table2.colm2 = <some value> ORDER BY RANDOM() LIMIT 20 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For mysql change RANDOM() to RAND().