O'Reilly logo

Beginning Access™ 2007 VBA by Denise Gosnell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required