Database

Here’s a simple quick trick to update random rows in MySQL.

name head stomach
Thorpe Obazee healthy full
Random Guy light-headed empty
Another Random Guy sober full

MySQL Query

update people set stomach = 'empty' order by rand() limit 2;
1 row affected, taking 2ms

Results

Take note that random rows are affected. Sometimes rows chosen by random could have the value already. This won’t affect them.

In this sample, Random Guy and Another Random Guy were chosen. Only Another Random Guy was updated.

name head stomach
Thorpe Obazee healthy full
Random Guy light-headed empty
Another Random Guy sober empty