INSERT Date rows between limits


Ive scratched my head over this and come up with nothing.

I need to add a row to a table for each date supplied on a booking form between date limits.

The table is simple

name = Bookings
fields =
Date (mysql format)

obviously I could just loop through the dates and insert one row per date, but thought there must be a way to do this within MySQL without the dreaded loop.


Perhaps the table is too simple? Change the table to have two dates, a start date and an end date.

Not an option Im afraid, Im implementing changes on a existing system. The client wont run to a rewrite of the bookings system.

Then the only other choice is you could use this type of syntax. There is a limit to how big the query can be, but I don’t remember what it is…

INSERT INTO example (example_id, name, value, other_value)VALUES (100, ‘Name 1’, ‘Value 1’, ‘Other 1’), (101, ‘Name 2’, ‘Value 2’, ‘Other 2’), (102, ‘Name 3’, ‘Value 3’, ‘Other 3’), (103, ‘Name 4’, ‘Value 4’, ‘Other 4’);

Bu**er it, I knew I was overlooking something obvious here !!

That’ll do for me, in reality the max number of entries would probably be 31 (one month), but research to see where the limit lies.