Retrieve data from one or more tables or queries.
Syntax
SELECT [DISTINCTROW] [predicate] { * | table.* | [table.]field1 [AS alias1]
[, [table.]field2 [AS alias2] [, …]]}
FROM tableexpression [, …] [IN externaldatabase]
[WHERE… ] [GROUP BY… ] [HAVING… ]
[ORDER BY… ] [WITH OWNERACCESS OPTION]
Key
predicate Restrict the number of records returned.
One of: ALL, DISTINCT, DISTINCTROW, or TOP.
* Return all fields from the table(s).
table The name of the table containing this field.
field1, field2 The fields containing the data to be retrieved.
If more than one field is listed, they are
retrieved in the order listed.
alias1, alias2 Names to use as column headers instead of
the original column names in table.
tableexpression The table or tables containing the data to retrieve.
externaldatabase The database containing the tables in tableexpression
if they are not in the current database.
SELECT statements will not change data in the database.
Use an asterisk (*) to select all fields in a table: SELECT * FROM T_Employees;
If a field name is included in more than one table in the FROM clause, precede it with table. name.
For example if the ProductID is in both T_Products and T_Sales:
SELECT T_Products.ProductID, T_Sales.qty
FROM T_Products INNER JOIN T_Sales
WHERE T_Products.ProductID = T_Sales.ProductID;
To return a different field name (and field object name), use the AS reserved word:
SELECT T_Products.ProductName As PartName
FROM T_Products
The As clause should also be used with aggregate functions (Sum, Count etc ) or any other queries that would return ambiguous or duplicate Field object names:
SELECT Count(ProductID)
AS ProductCount
FROM T_Sales;
“We don't pay taxes. Only the little people pay taxes” ~ Leona Helmsley
Related:
Delete - Delete records.
DCount - Count the number of records in a table/query.
Execute (SQL/VBA) - Execute a procedure or run SQL.
Insert - Add records to a table (append query).
Max (SQL) - Return the maximum value from a query.
Select Into - Make-table query.
Select-Subquery - SubQuery
Transform - Create a crosstab query.
Union - Combine the results of two SQL queries.
Update - Update existing field values in a table.