I need to populate table with random size of data for each dependency record.
First table is table of products (named products):
id || name
=== + =====
1 || name1
2 || name2
3 || name3
And the second table is table that contains displays of that product (named product_displays). Each display is another row:
id_product || date
=========== + ====
1 || d1
1 || d1
1 || d1
1 || d1
2 || d1
2 || d1
3 || d1
3 || d1
3 || d1
Like you can see date will always be the same value, but the number of rows that I need to insert should be random. And range for that number of returned rows I would like to specify in the query.
I except something like this:
INSERT INTO product_displays (id_product, date)
SELECT
p.id,
'2019-07-06'
FROM products p
JOIN table_with_random_num_of_rows_between_x_and_y t
For each product number of table_with_random_num_of_rows_between_x_and_y
rows should be random.