13一个完整的select语句[SELECT (Transact-SQL)]

Posted 东京八十万萝莉总教头

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了13一个完整的select语句[SELECT (Transact-SQL)]相关的知识,希望对你有一定的参考价值。

简介:

从数据库中检索行,并允许从 SQL Server 2012 中的一个或多个表中选择一个或多个行或列。 虽然 SELECT 语句的完整语法较复杂,但其主要子句可归纳如下:

[ WITH <common_table_expression>]

SELECT select_list [ INTO new_table ]

[ FROM table_source ] [ WHERE search_condition ]

[ GROUP BY group_by_expression]

[ HAVING search_condition]

[ ORDER BY order_expression [ ASC | DESC ] ]

可在查询之间使用 UNION、EXCEPT 和 INTERSECT 运算符,以便将各个查询的结果合并或比较到一个结果集中。

语法:

<SELECT statement> ::=  
    [WITH <common_table_expression> [,...n]]
    <query_expression> 
    [ ORDER BY { order_by_expression | column_position [ ASC | DESC ] } 
  [ ,...n ] ] 
    [ <FOR Clause>] 
    [ OPTION ( <query_hint> [ ,...n ] ) ] 
<query_expression> ::= 
    { <query_specification> | ( <query_expression> ) } 
    [  { UNION [ ALL ] | EXCEPT | INTERSECT }
        <query_specification> | ( <query_expression> ) [...n ] ] 
<query_specification> ::= 
SELECT [ ALL | DISTINCT ] 
    [TOP ( expression ) [PERCENT] [ WITH TIES ] ] 
    < select_list > 
    [ INTO new_table ] 
    [ FROM { <table_source> } [ ,...n ] ] 
    [ WHERE <search_condition> ] 
    [ <GROUP BY> ] 
    [ HAVING < search_condition > ]

 

以上是关于13一个完整的select语句[SELECT (Transact-SQL)]的主要内容,如果未能解决你的问题,请参考以下文章

oracle PLSQL 查询语句select t.*, t.rowid from PU.YK t

如何在子查询中使用 select 语句? (Postgres)

数据库原理-SELECT语句完整的句法

OracleSQL 中Select语句完整的执行顺序

T-SQL_select语句详解

Select 语句中的布尔逻辑