Simple Select Statements

To retrieve information from a relational database, SQL provides the simple SELECT statement. A simple SELECT statement takes the following form.

SELECT ColumnName, ColumnName FROM TableName;

The SELECT clause identifies one or more column names in a database table(s). After identifying the columns in the SELECT clause, you must tell the database which table(s) the columns live in using the FROM clause. It is customary in SQL to append a semicolon (;) after the SQL statement to indicate the statement's ending point.

To retrieve all rows in a database table, the wildcard character (*) can be used like this.


FROM Employees;

You can execute SQL queries in Access in one of a couple of ways. You can simply save your query, return to the Queries window, and double-click your newly saved query. Or, leaving your SQL View window open, select View, Datasheet View from the menu.

Another way to execute your SQL queries is to select Query, Run item from the menu, or click the red exclamation mark (!) on the Toolbar. Either way, the results from the preceding query running against the Northwind database are shown in Figure 8.4.

Viewing the results of a simple query.

Viewing the results of a simple query.

IP Microsoft Access - [Query 1 : Select Query]

0 0

Post a comment