Chapter 5 complex queries 5-3 associated subqueries

Source: Internet
Author: User
1. When comparing a set of records in a certain part of a table, the difference between a common subquery and an associated subquery can be used. When compared in a subdivided group, you need to use associated subqueries. The associated subquery is usually used in a language such as "limitation (binding)" or "restriction.

Key point: the key here is the condition of the WHERE clause added to the subquery. This condition specifies that the sales unit price and average unit price of each item are compared in the same product. Note: When using an associated subquery, you must add the table alias before the column name corresponding to the table and describe it in the form of "<Table Name>. <column Name>.

2. Associated subqueries are also used to split the set. From another perspective, in fact, the associated subquery is the same as the group by clause, and the set can be split.

3. The conditions must be written in the scope of the Association name in the subquery. The Association name has a valid range limit. Specifically, the Association name set in the subquery can only be used within the subquery. That is, "the internal can see the external, but the external can not see the internal ".

Chapter 5 complex queries 5-3 associated subqueries

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.