-2

I have a database that stores usernames, how can I randomly select a username from the database, by their ID.

So choose a random ID from the existing IDs inside of the database and return the username.

Thanks !

Jason McCreary
  • 71,546
  • 23
  • 135
  • 174
joshua
  • 67
  • 1
  • 7

1 Answers1

2

Use a simple ORDER BY.

select * from table order by rand() limit 1
Daan
  • 12,099
  • 6
  • 34
  • 51