I have a table employees:
+----------------+------------------+
| Field | Type |
+----------------+------------------+
| id | int(10) unsigned |
| persons_id | int(10) unsigned |
| restaurants_id | int(10) unsigned |
+----------------+------------------+
and a table bills:
+----------------+------------------+
| Field | Type |
+----------------+------------------+
| id | int(10) unsigned |
| customers_id | int(10) unsigned |
| employees_id | int(10) unsigned |
| restaurants_id | int(10) unsigned |
| date | date |
+----------------+------------------+
I want to insert 10,000 rows with an employees_id, restaurant_id and a date into the table bills by using cross joins. The table employees is filled with 15 rows (employees).
Currently I do following:
insert into bills (employees_id, restaurants_id, date) select e.id, e.restaurants_id, '2012-01-01' from employees e cross join employees e2 cross join employees e3 cross join employees e4 order by RAND() limit 10000;
With this query I get 50,625 rows (without to limit to 10,000) (15rows*15rows*15rows*15rows=50,625rows). Is there an more elegant solution to get 10,000 rows? So I don't have to write X times cross join employees eX.
I'm using MySQL. Thanks.