1
Answer

Using INSERT INTO inside a button to move data

EJ Bonino

EJ Bonino

7y
309
1
I am working on an application that will allow a user to post a work shift to a database then have another user accept that shift and take it in as their shift. I am able to have users post shifts to my database.
 
I have two tables on the same database Shifts and CoveredShifts. They both contain the same rows in their table ShiftID, Date, StartTime, EndTime, StoreNum, and Id. ShiftID is the Primary Key in both tables.
 
I have a button next to the row that is selectable for when someone wants to take the shift named "Cover This Shift" when a user clicks that button I want that row of data from the Shifts table to move to the CoveredShifts table and remove itself from the Shifts table.
 
I have researched INSERT INTO and came up with this
 
"INSERT INTO CoveredShift('null','ShiftID','Date','StartTime','EndTime','StoreNum','Id') SELECT 'ShiftID','Date','StartTime','EndTime','StoreNum','Id' FROM Shift";
 
However I am unsure how to fit that into a button in my CoveredShiftsController in MVC.
Answers (1)