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 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:


To select particular ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.