Comments - IF

5 years, 8 months ago Roberto Blandino
This comment has the status of 'removed' and can only be seen by you.

MariaDB [(none)]> IF 1=1 THEN SELECT 1 END IF; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'IF' at line 1

Testing de conditional, not working on "Server version: 10.1.35-MariaDB-1stretch mariadb.org binary distribution"

But otherwise:

MariaDB [(none)]> IF 1=1 THEN; SELECT 1; END IF; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 +---+

1

+---+

1

+---+ 1 row in set (0.00 sec)

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'END IF' at line 1

The documentation does not provide any functional example, I am trying to run:

MariaDB [dbgpon]> set @myId = (SELECT IF ((SELECT count(1) FROM `vlan` WHERE `gpon` = 1 AND `value`='1') = 1, TRUE, FALSE)); Query OK, 0 rows affected (0.00 sec)

MariaDB [dbgpon]> IF @myId=1 THEN; SELECT @myId; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 +-------+

@myId

+-------+

1

+-------+ 1 row in set (0.00 sec)

MariaDB [dbgpon]>

I hope a better documentation.

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.