![]() |
|
|||||||
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
#1
IP: 112.87.30.158
|
|||
|
|||
|
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. |
|
#2
IP: 112.87.30.158
|
|||
|
|||
|
You can use the following query:
Code:
UPDATE tableName SET win = 1 ORDER BY RAND() LIMIT 20000 |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Random MySQL date | Kimberling City | MySQL | 1 | 2015-04-18 11:09 PM |
| Add Random Dates to MySQL Database | Kersey | MySQL | 2 | 2015-04-18 11:06 PM |
| MySQL毫秒值和日期的指定格式的相互转换 | Kaitlin | MySQL | 0 | 2015-04-18 11:01 PM |
| mysql 帮助文档使用 | Haddam | MySQL | 0 | 2014-11-26 06:43 PM |
| Simple Steps to Change Your Table Prefix in WordPress | Abby | WordPress | 0 | 2014-04-14 03:40 PM |