把mysql数据库内一个字段year(int)下的所有内容都加1,请问sql语句怎样写? 要求不嵌套.
谢谢!

解决方案 »

  1.   

    mysql> create table testadd(id int not null,year int not null);
    Query OK, 0 rows affected (0.03 sec)mysql> select * from testadd;
    Empty set (0.00 sec)
    mysql> insert into testadd values (1,2009),(2,2008);
    Query OK, 2 rows affected (0.02 sec)
    Records: 2  Duplicates: 0  Warnings: 0mysql> select * from testadd;
    +----+------+
    | id | year |
    +----+------+
    |  1 | 2009 |
    |  2 | 2008 |
    +----+------+
    2 rows in set (0.00 sec)mysql> update testadd set year=year+1;
    Query OK, 2 rows affected (0.01 sec)
    Rows matched: 2  Changed: 2  Warnings: 0mysql> select * from testadd;
    +----+------+
    | id | year |
    +----+------+
    |  1 | 2010 |
    |  2 | 2009 |
    +----+------+
    2 rows in set (0.00 sec)mysql>
      

  2.   

    update table set year=year+1;
    2楼真强悍