请教一条SQL语句...

pocketpc 2005-07-08 10:39:47
update t set vcode = (select code from t1 where t.vcode=t1.fcode)
在access2000里面执行出现"操作必须使用一个可更新的查询"错误,
但执行update t set vcode = 1 时没有问题,顾已经排除了权限问题,现在
怀疑是access2000不支持,请各位给一个替换的sql:)
...全文
103 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
icedut 2005-07-08
  • 打赏
  • 举报
回复
lz去access版看看,这样的问题就很容易找到答案的
pocketpc 2005-07-08
  • 打赏
  • 举报
回复
SQL2000呀
但你要看清楚
update a set code = (select vcode from b where a.code=b.vcode)
===============================================================
你这个写的会问题,code已经和vcode相等了,就不用update了
:)
==============================================================
update t,t1 set t.vcode=t1.code
where t.vcode=t1.fcode
====================
ok
access测试通过
,谢谢,还是这个好用,分归你了
长风大叔 2005-07-08
  • 打赏
  • 举报
回复
update t set t.vcode=t1.code from t ,t1 where t.vcode=t1.fcode
icedut 2005-07-08
  • 打赏
  • 举报
回复
update t,t1 set t.vcode=t1.code
where t.vcode=t1.fcode
====================
ok
access测试通过
icedut 2005-07-08
  • 打赏
  • 举报
回复

数据库为bw,其中有两表jb,bw1
其中编号是双精度型 碑文是备注型

UPDATE jb SET jb.碑文 = bw1.碑文
WHERE jb.编号=bw1.编号 and jb.户主=bw1.户主;

语句是这样的,保存也通过,运行时。要求输入[bw1.碑文=][ bw1.编号][bw1.户主]

---------
试试:
UPDATE jb,bwl SET jb.碑文 = bw1.碑文
WHERE jb.编号=bw1.编号 and jb.户主=bw1.户主;
hanyuice 2005-07-08
  • 打赏
  • 举报
回复
SQL2000呀
但你要看清楚
update a set code = (select vcode from b where a.code=b.vcode)

update t set vcode = (select code from t1 where t.vcode=t1.fcode)
我的语句里只出现两个字段名:CODE和VCODE
但你的里面有三个字段名
是不是你把字段名弄错了
语句是没什么问题的,但有时会搞错一些小问题,后果还是蛮严重的!
所以会出现不可理新的查询!
icedut 2005-07-08
  • 打赏
  • 举报
回复
可能是access中的语法限制吧
pocketpc 2005-07-08
  • 打赏
  • 举报
回复
你是用什么数据库通过的?
pocketpc 2005-07-08
  • 打赏
  • 举报
回复
这句话一定问题没有的,在ORACLE ,SQLSERVER2000上都好用的,只是在ACCESS2000上不好用,所以我怀疑是数据库的原因.
pocketpc 2005-07-08
  • 打赏
  • 举报
回复
这句话一定问题没有的,在ORACLE ,SQLSERVER2000上都好用的,只是在ACCESS2000
hanyuice 2005-07-08
  • 打赏
  • 举报
回复
update a set code = (select vcode from b where a.code=b.vcode)

(所影响的行数为 6 行)

Ring1981 2005-07-08
  • 打赏
  • 举报
回复
update t set vcode = (select code from t1 where t.vcode=t1.fcode)
这句话本身没问题。

先检查(select code from t1 where t.vcode=t1.fcode)看看是什么?
hanyuice 2005-07-08
  • 打赏
  • 举报
回复
1,
select code from t1 where t.vcode=t1.fcode
你选择的是CODE,怎么后面又是FCODE?
2
你t1这个表里面是不是有几个CODE的值与表t的VCODE值一样呀
pocketpc 2005-07-08
  • 打赏
  • 举报
回复
这个已经试过了,不好用.
语法错误 (操作符丢失) 在查询表达式 t1.code from t中。
xuehoo688 2005-07-08
  • 打赏
  • 举报
回复
同意楼上!
zippooo 2005-07-08
  • 打赏
  • 举报
回复
楼上的正解
icedut 2005-07-08
  • 打赏
  • 举报
回复
(select code from t1 where t.vcode=t1.fcode)


select的结果是一个记录么

update t set vcode =t1.code
from t,t1
where t.vcode=t1.fcode


这样行不

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧