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


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)

Updated on: 03-Feb-2020

197 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements