I think you misunderstood how this is going to work. The expression ROUND(rand()*1000000) is not a constant, so it is going to re-evaluate it and generate a *different* random number for each line in the table. Apart from anything else, this is going to be slow because it will have to scan the whole table. There is an INDEPENDENT probability of one in a million that it will match each separate line, so you will get an average of one hit but, as you have found, sometimes none or two.
One way to solve this would be to use a user variable: SET @Random = ROUND(rand()*1000000) ; SELECT count, character FROM table_name WHERE count = @Random ; Alternatively, this might work: SELECT count, character FROM tableName ORDER BY rand() LIMIT 1 ; Alec Cawley ----------------------------------------------------------------------- I have database with table and 1 milions random characters. Key for searching each character is a counter from 1 to milion. when I execute statement: SELECT count, character FROM table_name WHERE count=ROUND(rand()*100000); Example: count || character || 1 dasarewr 2 adswarwrf 3 sfdqwerw 4 dfweqrqwe 5 asdfwerdfwe 6 fdwerwer 7 fsdwefwe 8 frefer ... ..... 9999 daswer 1000 fdferte .... ..... 999999 asdwerer 1000000 dasrewg RESULT: 1) Sometimes I get just one result like: 4352342 dcfsfwer 2)Sometimes I get TWO results! 1000 fdferte 999999 asdwerer 3) sometimes even THREE .... 4) sometimes NONE The select statement must to gave me just ONE result! Does anyone know what that is about? Does ROUND() have any bugs? Sorry for bad english. Elvir ---end of your message------- MySQL Development Team --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php