Skip to content

Instantly share code, notes, and snippets.

@yoku0825
Created April 11, 2013 14:49
Show Gist options
  • Save yoku0825/5363991 to your computer and use it in GitHub Desktop.
Save yoku0825/5363991 to your computer and use it in GitHub Desktop.
mysql55> CREATE FUNCTION rrand (start INT, end INT) RETURNS INT NO SQL RETURN RAND() * (end - start) + start;
Query OK, 0 rows affected (0.00 sec)
mysql55> SELECT rrand(1, 3);
+-------------+
| rrand(1, 3) |
+-------------+
| 2 |
+-------------+
1 row in set (0.00 sec)
mysql55> SELECT rrand(1, 3);
+-------------+
| rrand(1, 3) |
+-------------+
| 3 |
+-------------+
1 row in set (0.00 sec)
mysql55> SELECT rrand(1, 3);
+-------------+
| rrand(1, 3) |
+-------------+
| 1 |
+-------------+
1 row in set (0.00 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment