您要打印的文件是:SQL的详细语法介绍——对于学习数据库最基础知识一

SQL的详细语法介绍——对于学习数据库最基础知识一

作者:CLNARA    转贴自:CSDN    点击数:3893


Select

用途:

 从指定表中取出指定的列的数据

语法:

 

SELECT column_name(s) FROM table_name

 

解释:

从数据库中选取资料列,并允许从一或多个资料表中,选取一或多个资料列或资料行。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 ] ]

例:

 “Persons” 表中的数据有

LastName

FirstName

Address

City

Hansen

Ola

Timoteivn 10

Sandnes

Svendson

Tove

Borgvn 23

Sandnes

Pettersen

Kari

Storgt 20

Stavanger

选出字段名 LastName FirstName的数据

SELECT LastName,FirstName FROM Persons

返回结果:

LastName

FirstName

Hansen

Ola

Svendson

Tove

Pettersen

Kari

选出所有字段的数据

SELECT * FROM Persons

返回结果:

 

LastName

FirstName

Address

City

Hansen

Ola

Timoteivn 10

Sandnes

Svendson

Tove

Borgvn 23

Sandnes

Pettersen

Kari

Storgt 20

Stavanger