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

 About This Book

 Introduction of SQL

 MySQL Introduction and Installation

 Introduction of MySQL Programs

 PHP Programs and MySQL Server

 Perl Programs and MySQL Servers

 Java Programs and MySQL Servers

 Datatypes and Data Literals

 Operations and Expressions

 Character Strings and Bit Strings

Commonly Used Functions

Flow Control Functions

 Character String Functions

 Numeric Value Functions

 Date and Time Functions

 JSON Document Functions

 XML Document Functions

 Spatial Data Functions

 Cast Function

 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

 Locks Used in MySQL

 Defining and Calling Stored Procedures

 Variables, Loops and Cursors Used in Stored Procedures

 System, User-Defined and Stored Procedure Variables

 MySQL Server Administration

 Storage Engines in MySQL Server

 InnoDB Storage Engine - Primary and Secondary Indexes

 Performance Tuning and Optimization

 Bulk Changes on Large Tables

 MySQL Server on macOS

 Installing MySQL Server on Linux

 Connection, Performance and Second Instance on Linux

 Archived Tutorials

 References

 Full Version in PDF/EPUB