自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

SQL Server 中的 ALL、SOME 和ANY

數(shù)據(jù)庫 SQL Server
本篇給大家介紹SQL Server 中的 ALL、SOME 和ANY三個比較運算符,其中 SOME 和 ANY 是等效的。

 ALL、SOME 和 ANY是SQL Server 三個比較運算符,其中 SOME 和 ANY 是等效的

SOME 或 ANY:當(dāng)表達(dá)式與子查詢返回的至少一個值比較時滿足比較條件, SOME 或 ANY 就返回 TRUE。否則返回 FALSE

ALL :當(dāng)表達(dá)式與子查詢返回的所有值比較時滿足比較條件, ALL 就返回 TRUE。否則返回 FALSE

  1. create table test01 ( num int
  2.  
  3. insert into test01 
  4. select 5 union 
  5. select 6 
  6.  
  7. create table test02 (num int
  8.  
  9. insert into test02 
  10. select 2 union 
  11. select 3 union 
  12. select 6 union 
  13. select 7 
  14.  
  15. select * from test01 

  1. select * from test02 

 

至此 test01 表中有數(shù)據(jù): 5和 6 , test02表中有數(shù)據(jù) :2,3,6,7

  1. select num as num1 from test02 where num > all(select num from test01 ) 
  2. select num as num2 from test02 where num > any(select num from test01 ) 
  3. select num as num3 from test02 where num > some(select num from test01) 

 

  1. select num as num4 from test02 where num = all (select num from test01 ) 
  2. select num as num5 from test02 where num = any(select num from test01 ) 
  3. select num as num6 from test02 where num = some(select num from test01) 

 

  1. select num as num7 from test02 where num <> all (select num from test01 ) 
  2. select num as num8 from test02 where num <> any (select num from test01 ) 
  3. select num as num9 from test02 where num <>some(select num from test01) 

 

從上面的測試結(jié)果看,= any 或 = some 與平時使用的 in 是等效的。

 

責(zé)任編輯:姜華 來源: 今日頭條
相關(guān)推薦

2021-10-08 08:11:53

SQLAllSome

2010-09-24 18:03:38

SQL中EXISTS

2025-04-28 08:20:00

Python?函數(shù)代碼

2024-03-04 15:19:52

Python編程內(nèi)建函數(shù)

2022-11-30 07:17:53

2011-03-29 13:22:07

SQL Server臨時表表變量

2009-04-16 18:07:39

2010-09-01 16:44:26

SQL刪除主鍵

2010-11-10 15:23:55

SQL SERVER

2010-10-19 13:52:28

SQL Server事

2010-10-21 15:13:20

SQL Server系

2010-10-22 10:59:43

SQL Server的

2010-08-05 09:07:24

2010-11-12 13:08:36

動態(tài)sql語句

2009-04-16 17:44:31

2009-04-16 18:15:19

動作審核審核活動SQL Server

2022-02-09 10:07:03

LinuxSQL Server

2010-07-19 14:24:15

SQL Server盤

2021-10-13 06:49:13

SQL Server優(yōu)化

2011-08-15 12:55:54

SQL ServerOUTER APPLYCROSS APPLY
點贊
收藏

51CTO技術(shù)棧公眾號