![]() |
Flag large number random records in a MySQL database - one time only
In my database table I've got 5 columns, id, l_num, s_num, win, claimed. There are 415,000 records. How would I randomly select 20,000 of those records and update the record with a 1 in the win field?
I understand that I could use SELECT * FROM tableName ORDER BY RAND() LIMIT 20000 to select those random records, but I've also read that this type of select would be inefficient for a large number. I only need to perform this once on the database. Once all the records are flagged, we're simply checking against that flag one at a time. |
You can use the following query:
Code:
UPDATE tableName SET win = 1 ORDER BY RAND() LIMIT 20000 |
| All times are GMT +8. The time now is 12:16 AM. |
Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.