View Single Post
  #1   IP: 112.87.30.158
Old 2015-04-19, 08:18 AM
Galax city Galax city is offline
初级会员
 
Join Date: 2010-09-03
Posts: 1
Galax city 现在声名狼藉
Default 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.
Reply With Quote