当没有用 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)
posted @ 2021-01-27 09:58  大白菜!  阅读(348)  评论(0编辑  收藏  举报