TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

MySQL

MySQL INSTR Function

Overview

In this tutorial, we will learn about MySQL INSTR function. The INSTR function returns the
position in the string where the sub-string occurs. The function returns 0 if the sub-string is not
present in the string.

Syntax

The general syntax of the function is as follows:

INSTR(<string> , <sub-string>)

Examples

mysql> SELECT INSTR(‘MySQL’,’SQL’);
+———————-+
| INSTR(‘MySQL’,’SQL’) |
+———————-+
| 3 |
+———————-+
1 row in set (0.03 sec)

mysql> SELECT INSTR(‘MySQL’,’My’);
+———————+
| INSTR(‘MySQL’,’My’) |
+———————+
| 1 |
+———————+

MySQL INSTR Function

Let’s use the function to check if the sub-string is present in a string.

mysql> SELECT INSTR(‘Testing Documents’,’York’);
+———————————–+
| INSTR(‘Testing Documents’,’York’) |
+———————————–+
| 0 |
+———————————–+
1 row in set (0.00 sec)

The ‘York’ sub-string is not found in the string ‘Testing Documents’. So the function call returns
0. We can use this function and this condition to check if a sub-string is present in another string.

MySQL INSTR Function Example

—

MySQL Tutorials

MySQL Tutorials on this website:

https://www.testingdocs.com/mysql-tutorials-for-beginners/

For more information on MySQL Database:

https://www.mysql.com/

Related Posts

DataGrip Desktop Shortcut

MySQL /

Launch DataGrip on Windows

DataGrip Download

MySQL /

Install DataGrip IDE on Windows 11

MySQL Workbench Windows 11

MySQL /

New MySQL Connection in Workbench

MySQL Command-line Client

MySQL /

Command-Line MySQL Client

Start MySQL Client

MySQL /

Start MySQL Client on Windows 11

‹ MySQL CHAR_LENGTH Function› MySQL RPAD Function

Recent Posts

  • Update draw.io on Windows
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com