有表字段
 id    name    amount   amount2   successtime
 1   aa       10        2         null
更新字段amount2,当字段amount2数字大于等于amount时,更新successtime为当前时间,请高手指教,多谢
 

解决方案 »

  1.   

    update tablename set successtime=now() where amount2>=amount;
      

  2.   

    update 有表
    set successtime=now()
    where amount2>=amount
      

  3.   

    可问题时如果amount2<amount时,我还是需要更新amount2字段的,就是想每次更新amount2时判断一下是否达到了amount数,达到了,则同时更新时间
      

  4.   

    这和你一开始的说明已经不一样了。update 有表
    set amount2=100,successtime=if(100>=amount,now(),successtime)
    where id=1
      

  5.   

     (不要高估你的汉语表达能力或者我的汉语理解能力)
       建议你列出你的表结构,并提供测试数据以及基于这些测试数据的所对应正确结果。
       参考一下这个贴子的提问方式http://topic.csdn.net/u/20091130/20/8343ee6a-417c-4c2d-9415-fa46604a00cf.html
       
       1. 你的 create table xxx .. 语句
       2. 你的 insert into xxx ... 语句
       3. 结果是什么样,(并给以简单的算法描述)
       4. 你用的数据库名称和版本(经常有人在MS SQL server版问 MySQL)
       
       这样想帮你的人可以直接搭建和你相同的环境,并在给出方案前进行测试,避免文字描述理解上的误差。