Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

其他环境
¥10.00
程序里面SQL Server 2012抛出的异常,看不懂,也不知道怎么解决:Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

最佳答案

原因分析

子查询返回多个结果了

select *,

(select ID from t2 where t1.ID=t2.t1ID)

from t1

你的语句应该跟这个差不多

改成

select *,

(select top 1 ID from t2 where t1.ID=t2.t1ID)

from t1

即可

Yanne T2 被采纳率86%
2020-12-07 16:27
打赏 1 1
页面统计
166 访问
1 帮助
0.00 打赏

hierror 2019 © hierror.com 京ICP备13026190号-1

通知消息
  • 暂无任何消息