Inserting random characters to MYSQL Database

前端 未结 4 1312
说谎
说谎 2020-12-30 16:25

I want to add 100 entry to users table numbers field, random characters length is 10, all entry should be unique as well. How can i achieve this using MYSQL query code ?

4条回答
  •  被撕碎了的回忆
    2020-12-30 17:29

    in mysql u can do like :

    insert into table ( SUBSTRING(MD5(RAND()) FROM 1 FOR 10) , field2 , field3) , ( SUBSTRING(MD5(RAND()) FROM 1 FOR 10) , field2 , field3) , .........
    

    ..............

    in php see this 2 links :

    Short unique id in php

    What is the best way to generate a random key within PHP?

提交回复
热议问题