drop table test1;
create table test1
(id varchar(10),
weight int,
height int
);
delete from test1;
insert into test1 values('id20', 20, 150);
insert into test1 values('id30', 30, 140);
insert into test1 values('id50', 50, 130);
SELECT test1.*
FROM
test1
JOIN
(
SELECT id,weight FROM test1
ORDER BY RAND() * ( 1 / weight)
LIMIT 1
)
t2
USING (id)
;
(https://www.tek-tips.com/viewthread.cfm?qid=1296084)