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 |
选出所有字段的数据
返回结果:
LastName |
FirstName |
Address |
City |
Hansen |
Ola |
Timoteivn 10 |
Sandnes |
Svendson |
Tove |
Borgvn 23 |
Sandnes |
Pettersen |
Kari |
Storgt 20 |
Stavanger |
|