请问插入一条记录是这样的嘛:
 insert into 表名(字段1,字段2,...) values(值1,值2,...)那下面的是什么意思?怎么也能插入呢。请大侠们帮忙说明下语法,谢谢你们。
insert into t1 
select 1,'a' union all 
select 1,'a' union all
select 2,'b' union all
select 2,'b' union all
select 2,'b' union all
select 2,'c' union all
select 3,'c' union all
select 3,'c'
go

解决方案 »

  1.   

    select 后面的字段跟表t1字段要相符。
      

  2.   

    这个也是插入数据的一种方式。
    select  后面的字段个数和类型都要和表t1里面的字段多少和类型一致【自动增量除外】。
      

  3.   

    感谢楼上们的回答,那再请问:union all  是什么意思?
      

  4.   

    你先看一下
    select 1,'a' union all  
    select 1,'a' union all
    select 2,'b' union all
    select 2,'b' union all
    select 2,'b' union all
    select 2,'c' union all
    select 3,'c' union all
    select 3,'c'
    结果。
    实际上就是相当于
    insert into tb
    select * from ta
      

  5.   

    UNION 将数据并在一起
    你看一下
    select 1,2,3 
    union all
    select 4,5,6
    union all
    select 1,2,3/*
    ---------- ----------- -----------
    1           2           3
    4           5           6
    1           2           3
    */
    如果不加all
    select 1,2,3 
    union 
    select 4,5,6
    union 
    select 1,2,3则去除相同的
    /*
    ----------- ----------- -----------
    1           2           3
    4           5           6
    */
      

  6.   


    UNION 将数据并在一起
    你看一下
    select 1,2,3  
    union all
    select 4,5,6
    union all
    select 1,2,3/*
    ---------- ----------- -----------
    1 2 3
    4 5 6
    1 2 3
    */
    如果不加all
    select 1,2,3  
    union  
    select 4,5,6
    union  
    select 1,2,3则去除相同的
    /*
    ----------- ----------- -----------
    1 2 3
    4 5 6
    */
      

  7.   

    不合并  重复行  http://wenku.baidu.com/view/31d9760102020740be1e9bfe.html