當沒有用 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