How can we pass an empty string as a parameter to BIT_LENGTH() function and what would be returned by MySQL?

MySQLMySQLi Database

Whenever we want to pass an empty string as a parameter to BIT_LENGTH() function then we must have to pass blank quotes (even without any space). It cannot pass without quotes because MySQL then resembles it as the function without any argument and returns an error. But, when we pass an empty string with blank quotes then MySQL will return 0 as output. It can be understood with the following example as well −

Example

mysql> Select BIT_LENGTH();
ERROR 1582 (42000): Incorrect parameter count in the call to native function 'BIT_LENGTH'

mysql> Select BIT_LENGTH('');
+----------------+
| BIT_LENGTH('') |
+----------------+
| 0              |
+----------------+
1 row in set (0.00 sec)
raja
Published on 19-Feb-2018 13:59:36
Advertisements