MySQL Tutorial/Procedure Function/Operator
Версия от 13:44, 26 мая 2010; (обсуждение)
Boolean operator: NOT
mysql> delimiter $$
mysql>
mysql>
mysql> CREATE PROCEDURE myProc()
-> BEGIN
-> DECLARE a INT DEFAULT 2;
-> DECLARE b INT DEFAULT 3;
-> DECLARE c FLOAT;
->
-> IF NOT (a=b) THEN
-> SELECT "a is not equal to b";
-> END IF;
-> END$$
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> delimiter ;
mysql> call myProc();
+---------------------+
| a is not equal to b |
+---------------------+
| a is not equal to b |
+---------------------+
1 row in set (0.02 sec)
Query OK, 0 rows affected (0.02 sec)
mysql> drop procedure myProc;
Query OK, 0 rows affected (0.00 sec)
mysql>
Logic operator
mysql>
mysql> delimiter $$
mysql>
mysql> CREATE PROCEDURE myProc()
-> BEGIN
-> DECLARE a INT DEFAULT 2;
-> DECLARE b INT DEFAULT 3;
-> DECLARE c FLOAT;
->
-> IF (a<b) THEN
-> SELECT "a is less than b";
-> END IF;
-> END$$
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> delimiter ;
mysql> call myProc();
+------------------+
| a is less than b |
+------------------+
| a is less than b |
+------------------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.02 sec)
mysql> drop procedure myProc;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql>
mysql>