求一条Sql修改语句~~?

来源:百度知道 编辑:UC知道 时间:2024/06/22 10:12:52
有两个表 news(信息表) beclass(栏目表)
news(id,beclass,betype,news,...)
beclass(id,beclass,betype)

需要设置
news.beclass=beclass.beclass where news.betype=beclass.betype

我的SQL语句
update soso set soso.beclass=beclass.beclass
where soso.betype=beclass.betype;

这样不对.
列前缀 'beclass' 与查询中所用的表名或别名不匹配。

该怎样赋值?
基本上解决了,
我还是把beclass.beclass字段中的八个值单独一个个拿出来然后赋值给news.beclass

分开赋值总算解决了,
我还是比较倾向于3楼的,没去试(把我的几万条数据给赋没了可不好).

如果是Oracle的应该这么写,sqlserver下没验证过
update news a set a.beclass=
(select b.beclass from beclass b where a.betype=b.betype)
where exists
(select 1 from beclass b where a.betype=b.betype);

你要改什么?

update soso set soso.beclass=beclass.beclass
where soso.betype=beclass.betype;

update news set beclass=beclass.beclass from beclass where news.betype=beclass.betype

试试这样可以吗?