I just curious about updating mysql table record (in connection with php) as follows.
Update a value. Eg: In mysql table it has value “100”. User wants add “50” to that value. Using php code pass “50” to mysql table and it adds “50” to “100” and update to “150”.
Append data to a existing value. Eg: There is already a number in mysql table field “Contact” (0123456789)and new number should be append to the same field and separate using a comma or something (0123456789, 9876543210). Not using fields contact1, contact2 etc.
I am asking this normally we retrieve all the data from the table and do all the mathematical operations and after all we overwrite and update the table. Is there a way in the dbms to manage this kind of situation?
for 1 you could use
set col =col + 50
and for two you could use
set contact = case when contact is null then '12345' else concat(contact, ', 12345') end
but using csv in a database is only a good thing in certain situstions. This is not one of them I think. I would use a one to many relation with a seperate table. Consider the following.
removing one contact number means parsing the string and creating a new value.
find people with a certain number
ordering by number
注意:本文来自Hello, buddy!。本站无法对本文内容的真实性、完整性、及时性、原创性提供任何保证,请您自行验证核实并承担相关的风险与后果!
CoLaBug.com遵循[CC BY-SA 4.0]分享并保持客观立场,本站不承担此类作品侵权行为的直接责任及连带责任。您有版权、意见、投诉等问题,请通过[eMail]联系我们处理,如需商业授权请联系原作者/原网站。