如题目,我想实现在update的时候,自动把当天日期信息更新到表的
period字段里,date数据是以下格式2009-04-30update data_clean.provide_statuss as a
set a.period=date();
可以这样写吗

解决方案 »

  1.   

    update data_clean.provide_statuss as a
    set a.period=curdate();
     
      

  2.   

    可以但当天日期用curdate()mysql> create table t3 (id int,cd date);
    Query OK, 0 rows affected (0.11 sec)mysql> insert into t3 values (1,curdate());
    Query OK, 1 row affected (0.08 sec)mysql> update  t3 set cd=curdate();
    Query OK, 0 rows affected (0.11 sec)
    Rows matched: 1  Changed: 0  Warnings: 0mysql>
      

  3.   

    友情提醒:如果字段是timestamp类型,create table date00 (aa timestamp);
    insert into date00 values(null);
    update {$table} set {$field}=null
    来设置当前时间