# Find A String In A String
__*INSTR function*__
__*LOCATE function*__
__*POSITION function*__
+ **`INSTR(), LOCATE(), POSITION()`**: return the position of the specified string in another string
  + For example: **`SELECT INSTR('TiDB','DB'), INSTR('TiDB','D'), LOCATE('DB', 'TiDB'), POSITION('DB' IN 'TiDB');`**  
+ **`LOCATE(searchstr, str, pos)`**: where pos specifies the starting position of the search:
  + For example: **`SELECT LOCATE('DB', 'TiDB is a NewSQL style DB', 7);`**  
```
tidb> SELECT INSTR('TiDB','DB'), INSTR('TiDB','D'), LOCATE('DB', 'TiDB'), POSITION('DB' IN 'TiDB');
+--------------------+-------------------+----------------------+--------------------------+
| INSTR('TiDB','DB') | INSTR('TiDB','D') | LOCATE('DB', 'TiDB') | POSITION('DB' IN 'TiDB') |
+--------------------+-------------------+----------------------+--------------------------+
|                  3 |                 3 |                    3 |                        3 |
+--------------------+-------------------+----------------------+--------------------------+
1 row in set (0.00 sec)
tidb> SELECT LOCATE('~!@DB@!~', 'TiDB is a NewSQL style DB', 7);
+----------------------------------------------+
| LOCATE('DB', 'TiDB is a NewSQL style DB', 7) |
+----------------------------------------------+
|                                           ~!@24@!~ |
+----------------------------------------------+
1 row in set (0.00 sec)
```

------------------------------------------------------------
- **`INSTR()`**  return the index of the first occurrence of the substring
- **`LOCATE()/POSITION()`**  return position of the first occurrence of the substring
