A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 刘长路 中级黑马   /  2012-9-25 21:02  /  2319 人查看  /  6 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

insert into T_City(quhao) values ('0531') where City='济南'   
insert into T_City(quhao) values ('0532') where City='青岛'  
insert into T_City(quhao) values ('0533') where City='淄博'
insert into T_City(quhao) values ('0538') where City='泰安'
insert into T_City(quhao) values ('0535') where City='烟台'
insert into T_City(quhao) values ('0311') where City='石家庄'
insert into T_City(quhao) values ('0315') where City='唐山'
insert into T_City(quhao) values ('0355') where City='秦皇岛'
insert into T_City(quhao) values ('0312') where City='保定'
insert into T_City(quhao) values ('0316') where City='廊坊'
insert into T_City(quhao) values ('0371') where City='郑州'
insert into T_City(quhao) values ('0375') where City='平顶山'
insert into T_City(quhao) values ('0377') where City='南阳'
insert into T_City(quhao) values ('0379') where City='洛阳'
insert into T_City(quhao) values ('0391') where City='焦作'
insert into T_City(quhao) values ('0373') where City='新乡'
谁能看出来哪里错了啊,我纠结了好久啊,求大师指导本菜鸟

VOU9ZWG(FAO[ZR$%T9K}H@D.jpg (81.32 KB, 下载次数: 50)

VOU9ZWG(FAO[ZR$%T9K}H@D.jpg

评分

参与人数 1技术分 +1 收起 理由
宋天琪 + 1

查看全部评分

6 个回复

倒序浏览
本帖最后由 李阳_TickTock 于 2012-9-25 21:23 编辑

楼下说的对


不改哪成,多丢人

点评

晕。。。你改了啊!刚看你不是这么写的耶  发表于 2012-9-25 21:18
回复 使用道具 举报
本帖最后由 张青江 于 2012-9-25 21:24 编辑

insert into 表名(字段名) values(值)    这是语法!

后面不可以跟where条件! 因为这是一条插入语句,不是修改语句,也不是查询语句!

我之后又修改了下,给你一个  数据库修改的语法吧:

update  表明  set  字段=新值 where  条件

上面的条件里面,包括了很多我们可能用到的条件:
比如一个字段的值是多少  id=8 则修改所有id=8的数据
比如 id>8  则修改id大于8 的所有数据







评分

参与人数 1技术分 +1 收起 理由
宋天琪 + 1

查看全部评分

回复 使用道具 举报
都看不出来你这是向表中插入还是修改了
回复 使用道具 举报
我想你是将区号插入指定的对应的城市的数据中吧!
用update!
update  T_City  set quhao='0531' where City='济南'   
update T_City  set quhao='0532' where City='青岛'  
update  T_City  set quhao='0533' where City='淄博'
update  T_City set quhao='0538' where City='泰安'
update  T_City set quhao='0535' where City='烟台'
update  T_City set quhao='0311' where City='石家庄'
update  T_City set quhao='0315' where City='唐山'
update  T_City set quhao='0355' where City='秦皇岛'
update  T_City set quhao='0312' where City='保定'
update  T_City set quhao='0316' where City='廊坊'
update  T_City set quhao='0371' where City='郑州'
update  T_City set quhao='0375' where City='平顶山'
update  T_City set quhao='0377' where City='南阳'
update  T_City set quhao='0379' where City='洛阳'
update  T_City set quhao='0391' where City='焦作'
update  T_City set quhao='0373' where City='新乡'

评分

参与人数 1技术分 +1 收起 理由
宋天琪 + 1

查看全部评分

回复 使用道具 举报
只说一点试试看。成功了给个回复。
insert into T_City(quhao) values ('0531') where City=N'济南';
在汉字前加N

评分

参与人数 1技术分 +1 收起 理由
宋天琪 + 1

查看全部评分

回复 使用道具 举报
郎乐乐 发表于 2012-9-26 12:36
只说一点试试看。成功了给个回复。
insert into T_City(quhao) values ('0531') where City=N'济南';
在汉 ...

update是正解,这个还是不行
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马