When MySQL LOCATE() function returns NULL as the output?

MySQLMySQLi Database

It will return NULL as the output when the value of either first argument i.e. substring or the value of second argument i.e. substring is NULL. Example below will demonstrate it −

Example

mysql> Select LOCATE(NULL,'Ram is a good boy')As Result;

+--------+
| Result |
+--------+
| NULL   |
+--------+

1 row in set (0.00 sec)

mysql> Select LOCATE('Ram',NULL)As Result;

+--------+
| Result |
+--------+
| NULL   |
+--------+

1 row in set (0.00 sec)
raja
Published on 20-Feb-2018 07:11:04
Advertisements