I want to randomly create a number of an user id, but it shouldn't be repeated/duplicated.
I wanted to ask if there is a good approach in general if my aim is to INSERT it into in a MySQL database? I don't want to create a new user. Its for another table.
I want to insert random data with random user id's to create test-comment entries users have made, but not I want to display different users. That's why I need it. It's not about autoincrementing with primary key in the main user table. I want to fill out a comment section
Example:
user_id
: 54,34,30
randomy generated with PHP (mt_rand()
function). Now I have about 1000 users I want to randomize, but there's still a chance it could be repeated at some point. So let's say now these are the values: 54,54,32
This means it will insert a same user twiche in further steps, where I INSERT
this user id in the comment table.
So I just need another number randomly generated if it's already has been generated.