duanpo7282 2012-01-27 11:14
浏览 71

150个字段更新 - PHP + MYsql最佳解决方案

I am reading one XML field which has 150 tags ( fields ) in it.My XML field has the foll fields

productid, name and soon... 150 fields

The feeds shows me the data which is EITHER a NEW record or the DATA which is updated.

I know how to read, insert, update data in PHP/Mysql.

My main concern is that when there is an UPDATE, do i have to write UPDATE statement for all 150 fields ? Is there any shortcut to UPDATE only the fields that has been changed ?

Is it the STANDARD METHOD to write UPDATE name SET name = name, WHERE ... for ALL 150 fields ?

Or is there any SMART solution for doing this, because i dont think its best solution to update all fields ( if anyone of the field is updated )

  • 写回答

3条回答 默认 最新

  • doutangguali32556 2012-01-27 11:21
    关注

    You can update all 150 fields with just one query.

    UPDATE tbl SET field1 = val1, field2 = val2, ..., fieldn = valn WHERE condition
    

    It sounds like you're concerned about whether it's feasible to update all 150 fields in one query, and I don't see an issue with that. Alternatively, you would have to first select the tuple from the database, then compare each of the 150 fields, and update the database. That seems like a lot more work than just updating everything. That's two queries and a lot of comparisons instead of just one query.

    评论

报告相同问题?

悬赏问题

  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!