mandes — 2013-03-05T12:12:22-05:00 — #1
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
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.
davemaxwell — 2013-03-05T12:15:54-05:00 — #2
Perhaps the table is too simple? Change the table to have two dates, a start date and an end date.
mandes — 2013-03-05T12:20:19-05:00 — #3
Not an option Im afraid, Im implementing changes on a existing system. The client wont run to a rewrite of the bookings system.
davemaxwell — 2013-03-05T12:23:19-05:00 — #4
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');
mandes — 2013-03-05T12:27:38-05:00 — #5
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.