收藏本站 收藏本站
积木网首页 - 软件测试 - 常用手册 - 站长工具 - 技术社区
积木学院 > 程序开发 > ASP > 正文

SQL SELECT 语句

来源:互联摘选 日期:2008-02-15 11:27

SELECT

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

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 运算符,以将查询的结果组合成单个结果集。

语法

SELECT statement ::=
; query_expression ;
[ ORDER BY { order_by_expression column_position [ ASC DESC ] }
[ ,...n ]]
[ COMPUTE

{ { AVG COUNT MAX MIN SUM } ( expression ) } [ ,...n ]
[ BY expression [ ,...n ] ]

]
[ FOR { BROWSE XML { RAW AUTO EXPLICIT }

[ , XMLDATA ]
[ , ELEMENTS ]
[ , BINARY base64 ]
}
]
[ OPTION ( ; query_hint ; [ ,...n ]) ]

; query expression ; ::=
{ ; query specification ; ( ; query expression ; ) }
[ UNION [ ALL ] ; query specification ( ; query expression ; ) [...n ] ]

; query specification ; ::=
SELECT [ ALL DISTINCT ]
[ { TOP integer TOP integer PERCENT } [ WITH TIES ] ]
; select_list ;
[ INTO new_table ]
[ FROM { ; table_source ; } [ ,...n ] ]
[ WHERE ; search_condition ; ]
[ GROUP BY [ ALL ] group_by_expression [ ,...n ]
[ WITH { CUBE ROLLUP } ]
]
[HAVING ;search_condition;]

推荐阅读

 

热点信息

 
强悍的草根IT技术社区,这里应该有您想要的!
Copyright © 2010 Gimoo.Net. All Rights Rreserved  京ICP备05050695号