* David V. Edelstein > I'm trying to create a select statement that will go into a table find the > number of rows in the table then select a single random row and > return it. I > am using Java/mySQL with the mm.mysql JDBC drivers. I've been > playing around > with the following statement but it doesn't seem to like the > MAX(user_id) in > the middle of it. Can anyone advise me on the correct way to execute this? > Thanks in advance! > > SELECT ROUND((MAX(user_id)-1)*RAND()+1) from people;
select @max:=max(user_id) from people; select round((@max-1)*rand()+1) from people limit 1; -- Roger --------------------------------------------------------------------- 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