I’m confused on the correct way to set up this query.
I have a table
create table devices_to_be_moved (
device_to_be_moved_id INT NOT NULL AUTO_INCREMENT,
device_id INT NOT NULL,
beginning_x FLOAT(5,2),
to_beginning_slot FLOAT(4,2) NOT NULL,
to_ending_slot FLOAT(4,2) NOT NULL,
from_rack INT NOT NULL,
to_rack INT NOT NULL,
date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
user VARCHAR(50),
notes TEXT,
accept BOOLEAN DEFAULT 0,
verdict BOOLEAN,
FOREIGN KEY ( device_id ) REFERENCES devices ( device_id ),
FOREIGN KEY ( from_rack ) REFERENCES racks ( rack_id ),
FOREIGN KEY ( to_rack ) REFERENCES racks ( rack_id ),
PRIMARY KEY ( device_to_be_moved_id )
);
when I fill out a form to add an entry.
Which works as the table gets updated.
When I click the link, it takes me to
so I can review my handywork.
Lets say I screwed up and reposition the object, I submit the form and get
But when I check the table, I notice an INSERT was performed.
I think my logic is screwed up as I was hoping for an update.
The PK (move_id=5) is in the URL of the 2nd screenshot (before I m ake any corrections, but how do I alter my query to perform the UPDATE part if the PK is allready set?
Thanks
How do I make it so I can run the UPDATE if I only change three values (beginning_x, beginning_slot, ending_slot) in that record