in reply to Username regex, MYSQL random

Is there in way in SQL to select a row by random, so if it havd 1000 rows it picked row 200.

There is, in MySQL, the option to ORDER BY RANDOM, but only in recent versions, from memory 3.23, because I tried it, got an error, and then found that my host was using 3.22.
--
($_='jjjuuusssttt annootthheer pppeeerrrlll haaaccckkeer')=~y/a-z//s;print;

Replies are listed 'Best First'.
Re^2: Username regex, MYSQL random
by tadman (Prior) on Nov 24, 2002 at 10:24 UTC
    That's the best way to do it, though it is platform dependent.
    my $row = $dbh->selectrow_arrayref(" SELECT ... FROM ... WHERE ... ORDER BY RANDOM LIMIT 1");
    That should return a single row as an array reference, chosen at random from all possible rows that meet your WHERE criteria.