1. 程式人生 > 其它 >當沒有用 EXISTS 引入子查詢時,在選擇列表中只能指定一個表示式

當沒有用 EXISTS 引入子查詢時,在選擇列表中只能指定一個表示式

技術標籤:javamysqlsql資料庫oracle

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