SQL Getting Started Classic (fifth edition) Ryan Stephens study notes Part IV: Building Complex database queries

Source: Internet
Author: User

14th: Using subqueries to define indeterminate data

1, sub-query and select in combination with

Select Colum from table where column, where columnb= (select Colum_name from ...);

2, sub-query and inset combined use

Insert table1 Select Column1 from table2 where cloumn2> (select ...);

Insert a few items in table two that meet the criteria into table 1, note: number of items inserted = number of Table1

3, sub-query and update use together

4, sub-query and delete in combination with

15th Chapter: Combining Multiple queries

1. Union

Select ID from Stu Union ID from Jobe; When the ID in the two table is the same, the output is not repeated.

2. UNION ALL

Select ID from STU UNION all ID from Jobe; When the ID in the two table is the same, the output repeats.

SQL Getting Started Classic (fifth edition) Ryan Stephens study notes Part IV: Building Complex database queries

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.