简体   繁体   中英

Update non-empty values only in mysql table

My issue is that I have a PHP FORM that is submitting values through more than 55 input-text-fields, into a MySQL table.

Now, when I use UPDATE feature, suppose for eg for 3 fields:

$sql="UPDATE pathology_test_rates SET bsugar_random='$bsugar_random', bsugar_fasting='$bsugar_fasting', bsugar_pp='$bsugar_pp'";

And then , if I want to update only 1 value, out of above 3, using PHP FORM, its making other 2 values empty. Whereas, I want other 2 values to remain un-disturbed.

How to do this ? Please help. M not using id in table.

您可以使用where条件进行更新,例如

$sql = "update datatwo set age = 30 where employeeid = 40;"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM