Database Operations-query (continued), database-Query

Source: Internet
Author: User

Database Operations-query (continued), database-Query
1. Common query conditions:
(1) Comparison =,>, <, >=, <= ,! = (Not equal to), <> (not equal to),!> (Not greater ),! <; Not + comparison operator
(2) determine the range between and, not between and
(3) determine the set in, not in
(4) character matching like, not like
(5) null is null, is not null
(6) multiple conditions (logical operations) and, or, not
2. Aggregate functions
Count ([distinct | all] *)/* count the number of tuples */
Count ([distinct | all] <column Name>)/* count the number of values in a column */
Sum ([distinct | all] <column Name>)/* calculates the sum of values in a column (this column must be numeric )*/
Avg ([distinct | all] <column Name>)/* calculate the average value of a column (this column must be numeric )*/
Max ([distinct | all] <column Name>)/* calculate the maximum value in a column */
Min ([distinct | all] <column Name>)/* calculates the minimum value in a column */
If the distinct phrase is specified, it indicates that duplicate values in the specified column must be canceled during calculation.
If the all phrase is specified, the recurrence value is not canceled. All is the default value.
3. Connection Query

(1) equi and non-equi join query

Format: [<Table Name 1>.] <column name 1> <comparison operator> [<Table name 2>.] <column name 2>
The comparison operators include =,>, <,> =, <=, and ,! = (Or <>)
In addition, the link predicates can also be in the following form:
[<Table Name 1>.] <column name 1> <comparison operator> [<Table name 2>.] <column name 2> and [<Table name 2>.] <column name 3>
When the link operator is =, it is called equijoin, and other operators are called non-equijoin.
(2) Self-connection
(3) Outer Join: stores discarded tuples In the result link, and fills in the blank value (null) on other attributes. Therefore, this connection is called an outer join.
(4) composite condition join: The where clause contains multiple join conditions
In addition to connecting two tables and connecting a table to itself, a join operation can also be connected to more than two tables. The latter is usually called a multi-table join operation.
4. nested query: A subquery can also be nested with other subqueries.
Note: The order by clause cannot be used in the select statement of a subquery, and the group by clause cannot sort the final query results.
(1) subqueries with IN predicates
(2) subqueries with operators
(3) subqueries with any (some) or all
(4) subqueries with exists

Related Article

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.