日期:2014-05-18  浏览次数:20403 次

插入语句该怎么写
要写入的表结构为:
create   table   vote
(
vid   int   identity(1,1)   primary   key,
num   tinyint   not   null,
name   varchar(10)   not   null,
t1   tinyint   not   null,
t2   tinyint   not   null,
t3   tinyint   not   null,
t4   tinyint   not   null,
t5   tinyint   not   null,
t6   tinyint   not   null,
t7   tinyint   not   null
)
我的问题是从别的表中用select语句得到t1-t7的字段,可是num和name字段不想用select语句得到,而是用一个指定的值,比如说num我给它的值是88,而name的值我就指定为 '张三 ',我写的是:
insert   into   vote   88, '张三 ',select   top   10000   t1,t2,t3,t4,t5,t6,t7   from   ok   where   zong   between   95   and   115   and   t1   in(5,6)   and   t2   in(10,11,13,15)   and   t3   in(13,15,16,18)   and   t4   in(18,20,22,23)   and   t5   in(22,24,25,28)   and   t6   in(26,27,29,31,33)   and   t7   in(13)   and   dan   between   2   and   5   and   shuang   between   2   and   5
结果说提示错误,不知道要怎么写sql语句才好了

------解决方案--------------------
insert into vote select top 10000 88, '张三 ',t1,t2,t3,t4,t5,t6,t7 from ok where zong between 95 and 115 and t1 in(5,6) and t2 in(10,11,13,15) and t3 in(13,15,16,18) and t4 in(18,20,22,23) and t5 in(22,24,25,28) and t6 in(26,27,29,31,33) and t7 in(13) and dan between 2 and 5 and shuang between 2 and 5

------解决方案--------------------
insert into vote select top 10000 88, '张三 ', t1,t2,t3,t4,t5,t6,t7 from ok where zong between 95 and 115 and t1 in(5,6) and t2 in(10,11,13,15) and t3 in(13,15,16,18) and t4 in(18,20,22,23) and t5 in(22,24,25,28) and t6 in(26,27,29,31,33) and t7 in(13) and dan between 2 and 5 and shuang between 2 and 5