Using Integer Values as Arguments in MySQL LOCATE Function



MySQL allows us to use integer values as the arguments of the LOCATE() function. We do not need to use quotes. It can be demonstrated with the help of the following example −

Example

mysql> Select LOCATE(5,1698235);
+-------------------+
| LOCATE(5,1698235) |
+-------------------+
|                 7 |
+-------------------+
1 row in set (0.00 sec)

mysql> Select LOCATE(56,1698235);
+--------------------+
| LOCATE(56,1698235) |
+--------------------+
|                  0 |
+--------------------+
1 row in set (0.00 sec)

mysql> Select LOCATE(23,1698235);
+--------------------+
| LOCATE(23,1698235) |
+--------------------+
|                  5 |
+--------------------+
1 row in set (0.00 sec)
Updated on: 2020-02-03T05:54:05+05:30

83 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements