Dear MySQL-ers, Using MySQL 4.1.20, I'm trying to do a complex query on a subset; well, complex to me, that is. :)
In Perl, I'm trying to get 4 random entries from a subset "WHERE processed = '1'" and "columnId" is unique. Like so: $sth = $dbh->prepare ("SELECT columnId FROM queue WHERE columnId >= (SELECT FLOOR(MAX(columnId) * RAND()) FROM queue) IN (SELECT columnId FROM queue WHERE processed = '1') ORDER BY columnId LIMIT 4"); Seems to work fine. Only problem is, every once in a while I only get 3 numbers returned (or none at all, when I set "LIMIT 1"). Something to do with FLOOR and RAND, I reckon; but if I knew exactly what the problem was, I wouldn't asking. :) So, anyone here know what I'm doing wrong in my query? Thanks -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]