How to generate random numbers starting from 00000 to 99999 without repeating using MySQL only [closed]

1

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?

    
asked by anonymous 26.04.2018 / 15:03

1 answer

1

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.

    
26.04.2018 / 15:09