当没有用 EXISTS 引入子查询时,在选择列表中只能指定一个表达式。


当没有用 EXISTS 引入子查询时,在选择列表中只能指定一个表达式。
比如 select * from T_Employee where FNumber not in

( select top 5*   from T_Employee order by FSalary desc)
order by FSalary 在sql中执行出现错误

 

更正:select * from T_Employee where FNumber  not in
(select top 5 FNumber from T_Employee order by FSalary desc)
order by FSalary

因为:如果要用in,你后面select必须能只能由一个列组成,你的select后面跟了n个列,自然报那个错误了

如果是多个列 

select * from A where exists(
select b from tab where A.b = tab.B and A.b2 = tab.B2)



免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM