~drizzle-trunk/drizzle/development

1994.4.66 by Marisa Plumb
adding control flow functions
1
Control Flow Functions
2
======================
3
1994.4.67 by Marisa Plumb
CASE operator
4
There are four control flow functions: 
5
6
* CASE
7
* IF/ELSE
8
* IFNULL
9
* NULLIF
10
2194.5.3 by Andrew Hutchings
Markup fixes
11
Control flow functions return a value for each row processed, which represents the result of the comparison or condition specified. They can be used in ``SELECT``, ``WHERE``, ``ORDER BY``, and ``GROUP BY`` statements.
12
13
There are two basic examples of the ``CASE`` statment:
14
15
 1. ::
1994.4.68 by Marisa Plumb
edits to CASE function
16
17
	CASE value WHEN [compare_value] THEN result [WHEN [compare_value] THEN result ...] [ELSE result] END
1994.4.67 by Marisa Plumb
CASE operator
18
2194.5.3 by Andrew Hutchings
Markup fixes
19
In this version, result is returned when value is equal to compare_value. If nothing is matched, the result after ``ELSE`` is returned, or ``NULL`` is returned if there is no ``ELSE`` part.
1994.4.67 by Marisa Plumb
CASE operator
20
2194.5.3 by Andrew Hutchings
Markup fixes
21
 2. ::
1994.4.68 by Marisa Plumb
edits to CASE function
22
23
	CASE WHEN [condition] THEN result [WHEN [condition] THEN result ...] [ELSE result] END
24
2194.5.3 by Andrew Hutchings
Markup fixes
25
In this version, if [condition] is true, result is returned. If nothing is matched, the result after ``ELSE`` is returned, or ``NULL`` is returned if there is no ``ELSE`` part.
1994.4.68 by Marisa Plumb
edits to CASE function
26
2194.5.3 by Andrew Hutchings
Markup fixes
27
When [condition] is for equal comparison (=), this example syntax returns the same result as the first example.