Hello GP> Similar questions have been asked before. For example: GP> http://lists.mysql.com/mysql/184088
Thank you. I found something interesting: SELECT @rand_id:= CAST( 1 + MAX(id)*RAND() AS UNSIGNED) FROM history; SELECT * FROM history WHERE id >= @rand_id LIMIT 1; But this query can return empty results, if we use it with WHERE: SELECT @rand_id:= CAST( 1 + MAX(id)*RAND() AS UNSIGNED) FROM history; SELECT col1, col2 FROM table WHERE id >= @rand_id AND col3=123 LIMIT 5; ^^^^^^^^^^^^ :-( Sincerely, Michael, http://xoib.com/ http://3d2f.com/ http://qaix.com/ http://ryxi.com/ http://gyxe.com/ http://gyxu.com/ http://xywe.com/ http://xyqe.com/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]