-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
  • 69,176
  • 21
  • 125
  • 169
joshua
  • 67
  • 1
  • 7

1 Answers1

1

Use a simple ORDER BY.

select * from table order by rand() limit 1
Daan
  • 11,690
  • 6
  • 30
  • 49