In order to use a computer language, you usually give
instructions to an internal program. An instruction can be formulated as a
command. Examples are "give me food" or "touch your
head". Another type of instruction can be formulated as a question.
Examples are "what time is it?" or "Are you hungry?". The
sentence or group of words that constitute an instruction is also called a
statement.
To use the Structured Query Language (SQL), you create
SQL statements. A statement is then communicated to an internal program
called an interpreter or the SQL interpreter. The interpreter analyzes the
statement. If it is able to understand it, then it executes it. If it
cannot understand your statement, in a good (not necessarily the best)
case scenario, it may display an error. In a bad (not necessarily the
worse) case scenario, it may not display anything or it may display an
unreliable result. |
Formulating SQL Statements |
|
There are rules you should or must following in order
to create good instructions and reliable statements. Every SQL interpreter
has its own rules. This means that there are some differences in the rules
to follow when using Oracle, MySQL, Microsoft Access, DB2, Paradox,
Microsoft SQL Server, etc. This is not necessarily because the interpreters are
from different companies. For example, there are some differences in the
ways Microsoft Access and Microsoft SQL Server interpret some
instructions.
To create your statements, you will use two categories
of words. A keyword is a word that is internally used by the interpreter.
We will mention the keywords as we move on. The other words are those you
will make up on your own. SQL is not case-sensitive. This means that
CASE, Case, and case represent the same word.
|
After writing a statement, you must indicate
its end. This is because MySQL and MSDE work at the command prompt but the
interpreter must be
able to allow you to provide as long a statement as you want. That is, you
must be able to write a statement that spans various lines. Therefore,
when you are ready to hand the statement to the interpreter, you must let
it know:
- In MSDE, to indicate the end of a statement, type GO on its own line. This
means that you can type any part of the statement and press Enter at the
end of each line. In some cases, you will need to type the semi-colon to
indicate the end of an expression. Optionally, in all statements, before
typing GO on its own line, in the last line of your statement, you can
type the semi-colon. To execute a statement in MSDE, after typing GO,
you must press Enter
- In MySQL, to indicate the end of a statement, type the semi-colon
and press Enter
An operation is an action performed on one or more
values either to modify the value held by one or both of the values, or
to produce a new value by combining values. Therefore, an operation is
performed using at least one symbol and one value. The symbol used in an
operation is called an operator. A value involved in an
operation is called an operand.
A unary operator is an operator that performs its
operation on only one operand. A binary operator is an operator that
performs its operation on
two operands.
|
|
|