Questions tagged by "random"


0
 bounty
1
answers
Insert random number of rows into MySQL table using just SQL / stored routine
10 years ago • alex
I need to emulate some test data and so I need to be able insert a random number of rows, let's say from 1 to 100 rows, into MySQL table with the following schema: create table test_data ( id int ,create_date datetime ) id column must be unique b/c it is a primary key. create_date should contain the datetime when the row has been inserted. Please note that table is NOT EMPTY, i.e. it already contains a whole bunch of existing data. I want
Tags: ,
0
 bounty
1
answers
How to select a random row from a table in MySQL?
10 years ago • alex
Let's say I have a table with an integer column called ID being a primary key. It is unique and not-null, but we cannot guarantee it being sequential without gaps. I.e. we may have rows with ID = 1,2,6,7,8 and we do not have rows with ID 3,4,5 etc etc. This is why we cannot just generate a random number and get a row with that corresponding ID. Also we want all rows to have equal chance of being selected, so b/c of the gaps in ID values we ca
Tags: ,
1 from 2