sql 问题~

来源:百度知道 编辑:UC知道 时间:2024/07/02 21:35:22
一个表里有三个字段,a b c
update 表 set c=1 where a in(select top 2 a from 表 where b=2)
这个语句有什么问题么?为什么不对呢?

update 表 set c=1 where a in(select top 2 a from 表 where b=2) 这个语句有什么问题么?

你执行一下看有什么错误嘛,生命在于尝试!

top 只能1。
in的时候只能有一个结果。不能有多个。

update 表 set c=1 where a in(select top 2 a from 表 where b='2')

注意类型,不是数字类型的字段加单引号

SQL> ALTER TABLESPACE TEST READ ONLY

语法无错误,数据类型有误.
update 表 set c=1 where a in(select top 2 a from 表 where b=2) b如不为数值型或字符型会报错,比如Date类型等