Check MySQL version in function : VERSION « Information Functions « MySQL Tutorial






mysql>
mysql> delimiter $$
mysql>
mysql> CREATE PROCEDURE myProc()
    ->
    -> BEGIN
    ->   DECLARE major_version INT;
    ->
    ->   SET major_version=SUBSTR(version(),1,INSTR(version(),'.')-1);
    ->   IF major_version>=5 THEN
    ->      SELECT 'Good thing you are using version 5 or later';
    ->   ELSE
    ->      SELECT 'This version of MySQL does not support stored procedures',
    ->             'you must be dreaming';
    ->   END IF;
    ->
    -> END$$
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> delimiter ;
mysql> call myProc();
+---------------------------------------------+
| Good thing you are using version 5 or later |
+---------------------------------------------+
| Good thing you are using version 5 or later |
+---------------------------------------------+
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>








20.16.VERSION
20.16.1.VERSION() returns a string that indicates the MySQL server version.
20.16.2.Check MySQL version in function