mysql之any,some all(zz)

來源:互聯網
上載者:User

標籤:csdn   mysq   使用   sql   子查詢   nbsp   some   article   net   

  轉載自:http://blog.csdn.net/netcy/article/details/8464503

ALL和ANY操作符的常見用法是結合一個相對比較操作符對一個資料列子查詢的結果進行測試。它們測試比較值是否與子查詢所返回的全部或一部分值匹配。比如說,如果比較值小於或等於子查詢所返回的每一個值,<= ALL將是true;只要比較值小於或等於子查詢所返回的任何一個值,<= ANY將是true。SOME是ANY的一個同義字。

舉例:

create table s1(id int);

create table t1(id int);

insert into s1 select 1;

insert into s1 select 2;

insert into s1 select 3;

insert into t1 select 1;

insert into t1 select 2;

insert into t1 select 3;

SELECT s1.id from s1 where s1.id>any(select t1.id from t1)

返回結果為:

3

SELECT s1.id from s1 where s1.id>=any(select t1.id from t1)

返回結果為:

1

2

3

 

 

 當ALL、ANY或SOME操作符與"="比較操作符配合使用時,子查詢可以是一個資料表子查詢。此時,你需要使用一個資料行構造器來提供與子查詢所返回的資料行進行比較的比較值。

mysql之any,some all(zz)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.