~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to docs/functions/control_flow.rst

  • Committer: Brian Aker
  • Date: 2011-01-12 06:45:23 UTC
  • mto: (2073.1.4 catalogs)
  • mto: This revision was merged to the branch mainline in revision 2080.
  • Revision ID: brian@tangent.org-20110112064523-rqhptaqbph22qmj1
RemoveĀ customĀ error.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Control Flow Functions
2
 
======================
3
 
 
4
 
There are four control flow functions: 
5
 
 
6
 
* CASE
7
 
* IF/ELSE
8
 
* IFNULL
9
 
* NULLIF
10
 
 
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. ::
16
 
 
17
 
        CASE value WHEN [compare_value] THEN result [WHEN [compare_value] THEN result ...] [ELSE result] END
18
 
 
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.
20
 
 
21
 
2. ::
22
 
 
23
 
        CASE WHEN [condition] THEN result [WHEN [condition] THEN result ...] [ELSE result] END
24
 
 
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.
26
 
 
27
 
When [condition] is for equal comparison (=), this example syntax returns the same result as the first example.
 
 
b'\\ No newline at end of file'