If i have a select query that will always return 2-3 rows like so
id set currStatus idNew value
20 1 4 3 15.00
20 2 4 1 180.00
20 3 0 5 360.00
How can i use this data to create an insert statement for each row.
EDIT - I also need the idNew
values for another update statement after.
Here is my normal insert statement. Fields that start with an underscore are params coming from the stored procedure call.
INSERT INTO DisableHistory
(idCol, idNewCol, setCol, disabled_On_Date, disabled_Off_Date, disableNote, disablingUser, recallTime)
values
(id, idNew, set, NOW(), _disableOffDate, _disableNote, _disableUser, value);
So ideally the query would look like so if it was hardcoded
INSERT INTO DisableHistory
(idCol, idNewCol, setCol, disabled_On_Date, disabled_Off_Date, disableNote, disablingUser, recallTime)
values
(20, 3, 1, NOW(), _disableOffDate, _disableNote, _disableUser, 15.00),
(20, 1, 2, NOW(), _disableOffDate, _disableNote, _disableUser, 180.00),
(20, 5, 3, NOW(), _disableOffDate, _disableNote, _disableUser, 360.00);