Home > Database > SQL > What is the syntax structure of select statement in SQL?

What is the syntax structure of select statement in SQL?

青灯夜游
Release: 2020-08-29 11:30:46
Original
11979 people have browsed it

The syntax structure of the select statement in SQL is: "SELECT select_list [ INTO..] FROM table_name [ WHERE...] [ GROUP BY...][ HAVING...][ ORDER BY... ];".

What is the syntax structure of select statement in SQL?

The SELECT statement consists of a flexible series of clauses that together determine which data is retrieved. In addition to viewing information about tables and views in ordinary databases, users can also view SQL Server system information by using the SELECT statement. Before introducing the use of the SELECT statement, it is necessary to introduce the basic syntax structure and execution process of the SELECT statement.

The syntactic structure of the SELECT statement

Although the complete syntax of the SELECT statement is more complex, its main clauses can be summarized as follows:

SELECT select_list
[ INTO new_table]
FROM table_name
[ WHERE search_condition]
[ GROUP BY group_by_expression]
[ HAVING search_condition]
[ ORDER BY order_expression [ ASC|DESC ] ]
Copy after login

The only required clauses are the SELECT clause and the FROM clause, and the other clauses are optional. The specific meaning of each clause is as follows:

— SELECT clause: Specifies the columns returned by the query.

— INTO clause: Store the search results in a new table or view.

— FROM clause: used to specify the table or view where the referenced column is located. If there is more than one object, they must be separated by commas.

— WHERE clause: Specify the search criteria used to limit the rows returned. If the SELECT statement does not have a WHERE clause, the DBMS assumes that all rows in the target table satisfy the search criteria.

— GROUP BY clause: Specify the group used to place the output rows, and if the SELECT clause