A 表 字段  如下ID  modify   numID 是主键 且自增需要给 A表插入 最大 num+1 后值 我是这样的写的 但报错
INSERT INTO A VALUES(NULL,1,(select max(num) from A));如上要求如要通过怎么的 SQL 语句实现?

解决方案 »

  1.   

    INSERT INTO A
    select NULL,1,max(num) from A;
      

  2.   

    insert into A
    select null,1,max(num)+1
    from a
      

  3.   

    INSERT INTO A
    select NULL,1,max(num)+1 from A;
      

  4.   


    如果换成 update  需要怎样写呢
      

  5.   

    insert inot A VALUES select NULL,1,max(num)+1 from A
      

  6.   

    update a , (select max(num)+1 as k from A) b
    set a.num=b.k
      

  7.   

    insert: insert into a select null, 1, max(num)+1 from a;
    update: update a, (select max(num) as k from A) b set a.num = b.k+1 where a.num=b.k;