mercredi 20 septembre 2017

How to generate a unique random number when insert in MySQL?

I have a database for articles, and may want to generate unique random integer for each of them, so that the front end would visit through http://ift.tt/2ydep1f etc.

(The primary key ID are not considered)

I could achieve that in python backend, but how do we achieve this in MySQL sentences?

For example, a new article was done, and inserted into database:

INSERT into article_table (title, date, url_id) VALUES ('asdf', '11/11/1111', 8373734)

the url_id here is the unique random integer (1000~10000000) that automatically generated.




Aucun commentaire:

Enregistrer un commentaire