首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

请问一条insert语句的写法

2012-02-08 
请教一条insert语句的写法? createtabletest(idintidentity(1,1)primarykey,namevarchar(20),typevarchar(

请教一条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 = '半挂车 '

热点排行