Home >Database >Mysql Tutorial >When MySQL LOCATE() function returns NULL as output?

When MySQL LOCATE() function returns NULL as output?

WBOY
WBOYforward
2023-08-31 17:49:02986browse

当 MySQL LOCATE() 函数返回 NULL 作为输出时?

When the value of the first parameter (i.e. substring) or the second parameter (i.e. substring) is NULL, it will return NULL as output. The following example 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)

The above is the detailed content of When MySQL LOCATE() function returns NULL as output?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete
Previous article:What is a MySQL index?Next article:What is a MySQL index?