Mysql子查詢

來源:互聯網
上載者:User

標籤:

1單值(Scalar operand)

只有當外層(Parent)不為空白時,才返回相應值;否則返回NULL。

 note:For the subquery just shown, if t1 were empty, the result would be NULL even though s2 is NOT NULL.

2 用於操作符比較

[14.2.10.2 Comparisons Using Subqueries]

non_subquery_operand comparision_operator (subquery)

the comparision_operator is :=,>,>=,<,<=,!=,like ,<=>[和=功能相似,也可用於NULL值比較]

3 使用IN,ANY,SOME

operand comparison_operator ANY (subquery)

operand IN (subquery)

operand comoparison_operator SOME (subquery)

where comparison_operator is one of these operators:=,>, >=,<,<=,<>,!=

ANY,說明任何一個。只要右側運算元中的任一個滿足運算元條件,就為true.[ANY (不能是常量值)]

IN,包含[可以有常量值,多個用","分隔]。

SOME 與ANY 在功能上等價,只是在日常文法上不同。

4,使用ALL

operand comparison_operator ALL (subquery)

滿足所有,才返回true.

5, 行子查詢[Row subqueries]

值或列子查詢(如上所示)返回一個值或合格一列值;行子查詢返回一行資料,可能有多個列;行子查詢的合法操作符為:

=,>,<,>=,<=,<>,!=,<=>

只有多列同時滿足操作符才返回true,否則為false or NULL.

6,使用 EXISTS OR NOT EXISTS

當子查詢返回有資料時,EXISTS subquery 為true,AND NOT EXISTS subquery 為false.

7,關聯子查詢

是含有對外層查詢有引用的查詢。

8 用於From子句

9.子查詢錯誤

10,最佳化子查詢

【Development is ongoing,so no optimization tip is reliable for the long term.】開發進行中時,從長期發展看沒有可靠的最佳化技巧。

 

Mysql子查詢

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.