Syntax basics

Syntax basics

One of the most frequently used SQL statements is the SELECT statement, which extracts specified columns from one or more database tables to build a recordset. Here’s the basic syntax for a SELECT statement:

SELECT ColumnName FROM TableName

You can add line breaks, tabs, and other white space to your statements to clarify the logic: SQL ignores all white space. The following example shows a valid statement:

SELECT PaidDues
   FROM Members

The following keywords identify commonly used SQL commands:

Keyword

Description

SELECT

Retrieves the specified records from a database

INSERT

Adds a new record in a database table

UPDATE

Changes values in specified database records

DELETE

Removes specified database records

The following keywords are used to refine SQL statements:

Keyword

Description

FROM

Names the data source for an operation

WHERE

Sets one or more conditions for the operation

ORDER BY

Sorts the recordset rows in a specified order

GROUP BY

Groups the recordset by the specified select list items

The following operators specify conditions and perform logical and numeric functions:

Operator

Meaning

=

Equal to

LIKE

Like (wildcards OK)

<>

Not equal to

NOT LIKE

Not like (wildcards OK)

<

Less than

>

Greater than

<=

Less than or equal to

>=

Greater than or equal to

AND

Both conditions must be met, such as Louisiana AND Texas

OR

At least one condition must be met, such as Smith OR Smyth

NOT

Exclude the condition following, such as Paris NOT France

If the item being compared is text, place it in single quotes as in the following example:

...WHERE Country = 'Germany' 

If the item being compared is a date and you’re working with a Microsoft Access database, enclose it with # signs:

...WHERE DateOfBirth < #01/01/1970#

Other databases may have their own date conventions. Consult the database system’s documentation.

Some database systems may use non-standard SQL syntax in their products. Check your database system’s documentation.



Getting Started with Dreamweaver
Dreamweaver Basics
Working with Dreamweaver Sites
Laying Out Pages
Adding Content to Pages
Working with Page Code
Preparing to Build Dynamic Sites
Making Pages Dynamic
Developing Applications Rapidly