日期:2014-05-19  浏览次数:20556 次

请教一条insert语句的写法?

create   table   test
(
  id   int   identity(1,1)   primary   key,
  name   varchar(20),
  type   varchar(20)
)
insert   into   test   select   'a1 ', '半挂车 '
insert   into   test   select   'a2 ', '半挂车 '
insert   into   test   select   'a3 ', '半挂车 '
insert   into   test   select   'a4 ', '半挂车 '
insert   into   test   select   'a5 ', '半挂车 '
insert   into   test   select   'a6 ', '半挂车 '
drop   table   test
/*
想要在test表中插入数据,记录行数与type为 '半挂车 '的相同,name也一样,就是把 '半挂车 '更改为 '全挂车 '
如以下格式:
id         name               type
1             a1               半挂车
2             a2               半挂车
3             a3               半挂车
4             a4               半挂车
5             a5               半挂车
6             a6               半挂车

7             a1               全挂车
8             a2               全挂车
9             a3               全挂车
10           a4               全挂车
11           a5               全挂车
12           a6               全挂车
*/

------解决方案--------------------
insert into test select name, '全挂车 ' from test where type = '半挂车 '