By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table products(id int, name varchar(50));
insert into products(id) values (1), (2), (3);
create table product_displays(id_product int, pdate date);
insert into product_displays (id_product, pdate)
select p.id, '2019-07-06'
from products p
inner join (
select 1 n union all select 2 union all select 3 union all select 4 union all select 5
) t on t.n <= floor(1 + rand() * 5)
select * from product_displays order by id_product;
id_product | pdate |
---|---|
1 | 2019-07-06 |
1 | 2019-07-06 |
1 | 2019-07-06 |
2 | 2019-07-06 |
2 | 2019-07-06 |
2 | 2019-07-06 |
3 | 2019-07-06 |
3 | 2019-07-06 |
3 | 2019-07-06 |
3 | 2019-07-06 |