How to generate random numbers starting from 00000 to 99999 without repeating using MySQL only, the numbers can not start in 000, does anyone have any idea how I can do this?
How to generate random numbers starting from 00000 to 99999 without repeating using MySQL only, the numbers can not start in 000, does anyone have any idea how I can do this?
Good morning Bruno. I think you can use this here:
select FLOOR(RAND() * 99999)
Or rather:
BEGIN
DECLARE valorRand bigint;
set valorRand = select FLOOR(RAND() * 99999);
if exists (select * from tabela where coluna = valorRand) then
call meuRandon();
end if
return valorRand;
There you have to see how many times this can be repeated.