字段PostTime int(10) 属性:UNSIGNED
以前只用过MSSQL,现在要批量更新这个PostTime的时间为原来的值+5个月。。但是是一串例如1236747063这样的时间,我要怎么写SQL才能达到我的要求呢?

解决方案 »

  1.   

    update tb set posttime=posttime+ 13219200;[mysql> select from_unixtime(1236747063);
    +---------------------------+
    | from_unixtime(1236747063) |
    +---------------------------+
    | 2009-03-11 12:51:03       |
    +---------------------------+
    1 row in set (0.00 sec)mysql> select from_unixtime(1236747063+ 13219200);
    +-------------------------------------+
    | from_unixtime(1236747063+ 13219200) |
    +-------------------------------------+
    | 2009-08-11 12:51:03                 |
    +-------------------------------------+
    1 row in set (0.00 sec)把时间加上13219200就是5个月以后的时间。
      

  2.   

    SELECT unix_timestamp(date_add(FROM_UNIXTIME( 1249488000),interval 5 month))
      

  3.   

    SELECT unix_timestamp(date_add(FROM_UNIXTIME( 1249488000),interval 5 month))