id   tel  tel1  
1     a
2     a
3     a
4     a
5     a
6
将id 是 3-5 的 tel 中的内容 剪切下来 插入到 tel1字段中的sql语句如何写

解决方案 »

  1.   

    INSERT TB (TE1)SELECT TEL FROM TB WHERE ID BETWEEN 3 AND 5
      

  2.   

    UPATE  TB SET TE1=TEL FROM TB WHERE ID BETWEEN 3 AND 5
      

  3.   

    update 表 set tel1=tel where id id between 3 and 5??
      

  4.   

    update tel1 = tel ,tel=''  from  table  where id >2  and id <6
      

  5.   

    update tb1 
    set tel1=tel
    where id in(3,4,5)
      

  6.   

    update set tel1=tel,tel='' where id>=3 and id<=5
      

  7.   

    update TB SET TE1=TEL FROM TB WHERE ID BETWEEN 3 AND 5
      

  8.   

    update tb set tel1=tel where id id between 3 and 5
      

  9.   

    update tb set tel1=tel,tel='' where id>=3 and id <=5
      

  10.   

    不能将值 NULL 插入列 'ID',表 '02.dbo.02';列不允许有空值。INSERT 失败。INSERT 02(Tel1)SELECT Tel FROM 02 WHERE ID>10000 and id<20000
    提示出错啊
      

  11.   

    update TB SET TE1=TEL FROM TB WHERE ID BETWEEN 3 AND 5    这样写也不行啊  那表中0-2 tel1字段就为空了
      

  12.   

    tel tel1
    e
    e
    e     e
    e     e
    e     e
    e     e
    上面两行为空 出现这种情况了
      

  13.   

    那你结果想要什么样子,也是TEL??
      

  14.   

     tel tel1
     a
     a
     a
     a
     atel  tel1
    a    a
    a    a
    a    a
    a
    a第一张变成第二张
      

  15.   

    update tb set tel1=tel,tel=null where id between '3' and '5'--------------结果1 a
    2 a
    3 NULL a
    4 NULL a
    5 NULL a
    6 -------------楼主是不是想要这个结果
      

  16.   

    实在猜不透楼主想要什么, 这个哪里是 “将id 是 3-5 的 tel 中的内容 剪切下来 插入到 tel1字段中”
      

  17.   

     
    ID   Tel   Tel1
      1    A     null
      2    B     null
      3    C     null
      4    D     null
      5    E     null变成
     ID    Tel    Tel1
     1      A      C
     2      B      D
     3      c      E
     4      D      Null
     5      E      Null就是这样   
    公司要处理excel表    记录有几十万条     所有我就想用sql处理   
      

  18.   

    将需要的 select 入一临时表再处理.
      

  19.   

    update a set a.Tel1=b.Tel
    from tb a,tb b where a.id=b.id-2 and b.id between 3 and 5
      

  20.   

    select a.id id,a.tel tel,b.tell tell from tb a,tb b where a.id between 1 and 2
    and b.id between 3 and 5;