Check version with if statement : IF statement « Procedure Function « MySQL Tutorial






mysql>
mysql> delimiter $$
mysql>
mysql> CREATE PROCEDURE myProc()
    -> BEGIN
    ->
    ->     IF (INSTR(version(),'alpha')>0) THEN
    ->               SELECT 'Alpha release of MySQL';
    ->     ELSEIF (INSTR(version(),'beta')>0) THEN
    ->               SELECT 'Beta release of MySQL';
    ->     ELSE
    ->               SELECT 'Production release of MySQL';
    ->     END IF;
    ->
    ->
    -> END$$
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> delimiter ;
mysql>
mysql> call myProc();
+-----------------------------+
| Production release of MySQL |
+-----------------------------+
| Production release of MySQL |
+-----------------------------+
1 row in set (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> drop procedure myProc;
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql>








11.13.IF statement
11.13.1.IF
11.13.2.If statement with ELSEIF and ELSE
11.13.3.Using OR in an IF statement
11.13.4.Check version with if statement
11.13.5.IF statement in a LOOP statement