Specifications

DocSTAR Level 2 Service Training Workbook Page 23
How is an SQL statement structured?
As seen in the prior example, a well-structured SQL statement can be a very powerful
timesaving tool. On the other hand, a poorly structured SQL statement can be a very
destructive tool. It is recommended that you test your SQL syntax by first creating a
SELECT SQL to see if it will run as expected, it is also useful in determining how many
records will be affected by your proposed SQL statement. AS WITH ANY REPAIR TO A
DOCSTAR SYSTEM, MAKE A BACKUP COPY OF THE ENTIRE DOCSTAR
DIRECTORY BEFORE ATTEMPTING TO RUN AN SQL STATEMENT. THE OBJECT
IS TO REPAIR THE SYSTEM WITH NO CUSTOMER DATA LOSS. IF YOU MAKE A
BACKUP FIRST, AT THE VERY LEAST YOU WILL BE ABLE TO RETURN THE
SYSTEM TO THE CONDITION IT WAS IN BEFORE YOU MADE ANY ATTEMPTS AT A
REPAIR.
SQL Statements require proper syntax to perform the desired operation. In order to
structure an SQL statement properly you must understand what data types (found in the
design view of a table) you are dealing with and what components you will need. SQL
statements commonly used with the DocSTAR database involve the following data types
and components:
Common Data Types Defines the format of the data in a field
NUMBER; YES/NO Numeric values that are used with comparison operators
TEXT; MEMO Character strings, surrounded by quotation marks that are
used with comparison operators and/or string operators
DATE/TIME Dates, surrounded by # signs, that are used with
comparison operators
Statements/Action Words Defines a desired action
SELECT Selects records to be included from a specified table
SELECT COUNT (*) Selects record count from a specified table
UPDATE Updates records in a specified table
DELETE Deletes records in a specified table
INSERT INTO Inserts records into a specified table
SET Sets data in a field to a specified integer value or string
Clauses/Qualifiers When used with a wildcard character or an operator, defines a data
source or a desired condition/selection criteria
FROM Defines the (table) source of data
WHERE Defines a (field) condition to be met
AND Defines an additional (field) condition to be met
OR Defines an alternate (field) condition to be met
Operators/Conditions When used with a clause, defines a desired condition/selection
criteria
Comparison Operators
< Less than
<= Less than or equal to
> Greater than
>= Greater than or equal to
= Equal to
<> Not equal to
String Operators
& Used to combine strings
LIKE Used to compare strings