The syntax for if
and while
blocks looks like this:
if (expr
) {command list
}
while (expr
) {command list
}
An expression result is true if nonzero, false if zero. If the
expression begins with !
, the sense of the test
is reversed.
There is no provision for else
with
if
.
For a while
loop, make sure that the loop
includes some exit condition that eventually occurs. This can be
done by writing expr
so that it becomes
false at some point.
The allowable syntax for expr
is
$
,
var_name
!$
, a string
or integer, or
var_name
`
.
query
`
The opening {
must be separated from the
preceding )
by whitespace (such as a space or a
line break).
As of MySQL 4.1.23/5.0.42/5.1.18, variable references that occur
within `
are
expanded before the query is sent to the server for execution.
query
`