Skip to content

Instantly share code, notes, and snippets.

@jonpemby
Last active March 7, 2018 16:19
Show Gist options
  • Select an option

  • Save jonpemby/a2da452914e7968aebaea8cb60d52939 to your computer and use it in GitHub Desktop.

Select an option

Save jonpemby/a2da452914e7968aebaea8cb60d52939 to your computer and use it in GitHub Desktop.
MySQL random string from list
select elt(floor(1 + (rand() * @len)), "hello", "world", "this", "is", "a", "random", "list");
@jonpemby

jonpemby commented Mar 7, 2018

Copy link
Copy Markdown
Author

Edit

Fixed a NULL popping up - forgot to use FLOOR to keep random index within bounds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment