Something-mysql today.

Source: Internet
Author: User
Hi

I have something to play with today, how much can I learn?

1. MySQL

-----subquery and Connection (ii)-----

----Sub-query

A subquery, which is a SELECT clause that appears within other SQL statements

Note: A subquery is nested inside a query and must always appear in parentheses; it can contain multiple keywords or conditions; the outer query can be select,insert,update,set or do

The return of a subquery, which can be a scalar, a row, a column, or a subquery

Can be divided into three categories: the use of comparison operators =,>=, etc.; Not in; EXIST

----Using comparison operators to implement subqueries

--

Mysql> SELECT goods_id,goods_name,goods_price from Tdb_goods WHERE goods_price>=5391.30;

The numbers here can be used without a tube, which is an average of the previous gains.

So if you want to directly get the result of this average participation, write it with a subquery

Mysql> Select Goods_id,goods_name,goods_price from Tdb_goods WHERE goods_price>=, select ROUND (AVG (Goods_price), 2) from Tdb_goods);

As you can see here, the subquery is in parentheses, using the >=

--

When a subquery returns multiple results, and the main query is less than that, you can SOME the ALL keyword with any

Where any is the same as some, it is good to satisfy one of them, specifically which one depends on what operator is (e.g. > is greater than the minimum value).

All requests to meet all return requirements

Usage is written in front of sub-query parentheses

----subquery raised by in or not

In fact, the in and =all operators are equivalent, not in and =! All equivalent

Usage is similar

----EXIST

Returns a Boolean value with very little

The above describes something-mysql today, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.