Originally, I want to create a some sort of id for user, but I can't change my data table into unique
for several reason. So I have to generate unique random data manually, so I decide to do this:
SELECT CONCAT("B",FLOOR(10000 + RAND() * 89999)) AS random_number
FROM mmr
WHERE "random_number" NOT IN (SELECT rm FROM mmr) LIMIT 1
with FLOOR(10000 + RAND() * 89999)
I was able to get random data between 10000-99999 but it's still not unique.
mmr is large table with more than 2M data and rm type is varchar(12)
. The result I was expecting is Bxxxxx
I also tried to use not exists
but no result came in