Sub-query, also called nested query.
A query statement is used as a result set for other SQL statements, just as a query statement that is treated as a result set is called a subquery, as with a normal table.
There are two types of sub-queries:
One is to return only a single-valued subquery, at which point it can be used where a single value can be used, when a subquery can be considered a function that has a return value;
Another is a subquery that returns a column of values, at which point the subquery can be thought of as a data table that is temporarily present in memory.
Create a new department table, an employee table, and a department column number for each person in the employee table.
Sub-query Example:
Practice One:
Exercise two:
Exercise Three:
Example of a paged query statement:
See how many pages can be divided into a total:
Practice:
Subquery Practice One: Find out All information about people who are older than seven years old in the sales department
Exercise two: convert all numeric codes from a department in a haha table to a string display in a bumen table
Exercise three: Convert all the number codes from the department in the haha table to The string display in the Bumen table, and show each person's supervisor
Fundamentals of database Development-Lesson Plans-6 sub-queries