5.3. Introduction to SQL

Structured Query Language (SQL) is a special language for structuring commands that can communicate with databases. Various dialects of SQL statements include Jet SQL, ANSI SQL, and the vendor specific implementations of ANSI SQL such as T-SQL for SQL Server. The syntax of SQL you use varies slightly depending on underlying database. In this section, I cover SQL that is common to most databases.

SQL statements can be used with and without ADO. For example, a SQL statement can be specified as the RecordSource property to which a form can be bound. The examples in this section will illustrate using SQL statements with ADO.

Note that you can also view SQL statements in the Query Designer and have the Query Designer help you create SQL. If you select View SQL View from within a Query window, you can see the SQL statement that Access created for your statement. You'll learn how to write SQL statements without using a designer.

5.3.1. Retrieving Data Using SQL Select Statements

The Select statement allows you to retrieve records from one or more tables in a database and has a basic syntax as follows:

SELECT columns FROM tables WHERE where-clause ORDER BY columns
5.3.1.1. Select Clause

The Select clause specifies what columns in the underlying table or tables you want to retrieve. To retrieve all records in a certain table, use:

SELECT *

To select particular ...

Get Beginning Access™ 2007 VBA now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.