
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Which MySQL functions work as similar as LOCATE() function?
MySQL INSTR() and POSITION() function works similar as LOCATE() function. They both are synonyms of LOCATE() function.
INSTR() function also returns the position of the first occurrence of the substring after searching from the string. The syntax of INSTR() is as follows −
Syntax of INSTR()
INSTR(string, substring)
Here, String is the string from which MySQL will search and substring is the string which is to be searched.
Example
mysql> Select INSTR('Ram is a good boy', 'good')As Result; +--------+ | Result | +--------+ | 10 | +--------+ 1 row in set (0.00 sec)
POSITION() function also returns the position of the first occurrence of the substring after searching from the string. Syntax of POSITION() is as follows −
Syntax of POSITION()
INSTR(substring IN string)
Here, String is the string from which MySQL will search.
Substring is the string which is to be searched.
‘IN’ is a keyword.
Example
mysql> Select POSITION('good' in 'Ram is a good boy')As Result; +--------+ | Result | +--------+ | 10 | +--------+ 1 row in set (0.00 sec)
- Related Articles
- When MySQL LOCATE() function returns NULL as the output?
- What happens if I will use integer values as arguments of MySQL LOCATE() function?
- How MySQL LOCATE() function is different from its synonym functions i.e. POSITION() and INSTR() functions?
- Which function in MySQL returns the same output as BIN() function?
- What is the difference between MySQL LOCATE() and FIND_IN_SET() functions?
- When MySQL FIND_IN_SET() function returns NULL as output?
- What is the use of LOCATE() function in MySQL?
- Python Standard operators as functions
- Which MySQL function returns a specified number of characters of a string as output?
- How LOCATE() function can be used with MySQL WHERE clause?
- How does MySQL IF() function work?
- How number values be used as arguments in MySQL STRCMP() function?
- What MySQL returns if we use NULL, as both the arguments, as one of the argument and as a separator, in CONCAT_WS() function?
- How can I manage the start position of searching in MySQL LOCATE() function?
- MySQL CAST as DATE?

Advertisements