MySQL Tutorials - Herong's Tutorial Examples - v4.46, by Herong Yang
Flow Control Functions
Describes 4 types of flow control functions: CASE ... WHEN, CASE WHEN, IF and IFNULL.
MySQL supports 4 types of flow control functions, which return values based on some conditions.
"CASE value WHEN val_1 THEN res_1 WHEN val_2 THEN res_2 ... ELSE res_0 END" - Returns res_1 if value matches val_1, or res_2 if value matches val_2, ..., or res_0 if value matches none of the given values.
"CASE WHEN con_1 THEN res_1 WHEN con_2 THEN res_2 ... ELSE res_0 END" - Returns res_1 if con_1 is true, or res_2 if con_2 is true, ..., or res_0 if none of the given conditions is true.
"IF(condition, res_1, res_2)" - Returns res_1 if condition is true, otherwise returns res_2.
"IFNULL(res_1, res_2)" - Returns res_1 if res_1 is not null, otherwise returns res_2.
Table of Contents
MySQL Introduction and Installation
Introduction of MySQL Programs
Perl Programs and MySQL Servers
Java Programs and MySQL Servers
Character Strings and Bit Strings
Table Column Types for Different Types of Values
Using DDL to Create Tables and Indexes
Using DML to Insert, Update and Delete Records
Using SELECT to Query Database
Window Functions for Statistical Analysis
Use Index for Better Performance
Transaction Management and Isolation Levels
Defining and Calling Stored Procedures
Variables, Loops and Cursors Used in Stored Procedures
System, User-Defined and Stored Procedure Variables
Storage Engines in MySQL Server
InnoDB Storage Engine - Primary and Secondary Indexes
Performance Tuning and Optimization
Installing MySQL Server on Linux