MySQL Forums
Forum List  »  Newbie

Re: Update specific column only
Posted by: Barry Galbraith
Date: May 29, 2019 06:24PM

Quote

so 1 form submit would be set Column B = "Blah" where ID = 1 -- but leave the rest of that records unchanged.

UPDATE mytable SET B = "Blah" WHERE ID = 1;

Quote

another example might be on form submit set Column E = "Test" where ID = 19 -- but leave the rest of that records unchanged.

UPDATE mytable SET E = "Test" WHERE ID = 19;

Quote

ie set Column E = "Test" and Column A = "Day" where ID = 19 -- but leave the rest of that records unchanged.

UPDATE mytable SET E = "Test" , A = "Day" WHERE ID = 19;

Quote

What is confusing me is the part about leaving columns with no value from the form submit, unchanged.

Why? If you put all of the existing values for the row into the form, and edit one or more values, then write all of those values back to the row, then only those changed values are changed. All the unchanged values are overwitten with the same value.
It's up to you when you build the form what happens to populate the form in the first place, and what happens with the values from that form when it is submitted.

Good luck,
Barry.

Options: ReplyQuote


Subject
Written By
Posted
May 28, 2019 07:35PM
Re: Update specific column only
May 29, 2019 06:24PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.