#query
SELECT FLOOR(RAND() * 99999)
AS random_num
FROM YourTableName
WHERE "random_num"
NOT IN (
SELECT YourColumnName FROM YourTableName) LIMIT 1
DO
SELECT LEFT(UUID(), 8) INTO @var;
INSERT INTO col (@var);
WHILE there_is_a_unique_constraint_violation