-
-
Save hoodasaad/0d1ec89b45a119e8214992fcd91d43d7 to your computer and use it in GitHub Desktop.
Sql to Generate Random unique number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT uuid() AS 'rvkey' FROM `{$prefix}visit` WHERE 'rvkey' NOT IN (SELECT `vkey` FROM `{$prefix}visit`) LIMIT 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT SUBSTRING(MD5(RAND()) FROM 1 FOR 8) AS random_charachter | |
FROM `table` | |
WHERE "random_charachter" NOT IN (SELECT `field` FROM `table`) | |
LIMIT 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT FLOOR(RAND() * 9999999) AS random_num | |
FROM `table` | |
WHERE "random_num" NOT IN (SELECT `field` FROM `table`) | |
LIMIT 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment