lundi 16 novembre 2015

How to insert a new row in MySQL where primary key column is Unique and Random Number

I have a table with a primary index column that is:

ID | mediumint(8) | UNSIGNED ZEROFILL | PRIMARY

I have various columns of data to insert into the table and while I am doing it I want to also have the ID column created as a unique and random number between 15000001 and 15999999.

I have seen a number of ways to use MySQL to select random values based on what already exists in a table, but I have not been able to find what an INSERT INTO query statement would look like to do this.




Aucun commentaire:

Enregistrer un commentaire