doujing5726 2016-10-17 19:15 采纳率: 0%
浏览 94

当没有子查询时,为什么我在SQL Server上收到“子查询返回的值超过1”错误?

I'm getting the following error when trying to run a very simple query on a SQL Server database from a PHP script...

SQLSTATE[21000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. (SQL: select * from [NAVItems] where [Brand] = DELINTE)

As you can see, there is no subquery. I'm just trying to pull a list of product records of a specific brand. The strange thing is, it only happens with this one brand, DELINTE. For example...

select * from [NAVItems] where [Brand] = 'FALKEN';

...works fine.

Also, the query works for DELINTE if I change the selection to specific fields instead of *. For example...

select [Style] from [NAVItems] where [Brand] = 'DELINTE';

...also works fine.

But...

select * from [NAVItems] where [Brand] = 'DELINTE';

...keeps throwing the above error.

I'm so confused. Any idea why it might be doing this? Any and all help is greatly appreciated.

EDIT: I found the problem. Yes there was a subquery in the view, and there were some duplicate records in a related table, causing the error. Thanks for pointing me in the right direction!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 mmocr的训练错误,结果全为0
    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀