Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

Instr Function In Sql in SQL

Instr Function In Sql in SQL

INSTR Function in SQL

The INSTR function returns the position of the first occurrence of a substring within a string. If the substring is not found, it returns 0.


Syntax:

INSTR(string, substring)
  • string: The string to search within.

  • substring: The substring to find.


Example:

SELECT INSTR('Hello World', 'World') AS position;

Result:

position
7

Explanation: The substring 'World' starts at the 7th character in 'Hello World'.


Notes:

  • The position count usually starts at 1 (not 0).

  • If substring is not found, returns 0.

  • Supported in MySQL, Oracle, and some other databases (syntax may vary slightly).


Variant in Some Databases:

  • In SQL Server, use CHARINDEX(substring, string) instead.

  • In Oracle, INSTR(string, substring [, start_position [, occurrence]]) supports additional options.


If you want examples for a specific database or advanced usage, just ask!

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql