Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

InStr

Example

Find the position of the letter “t” in the string “Customer”.

SELECT InStr(“Customer”“t”AS MatchPosition;

Definition and Usage

The InStr() function returns the position of the first occurrence of one string within another, performing a case-insensitive search.

Syntax

InStr(startstring1string2compare)

Parameter Values

Parameter Description
start Optional. Specifies the starting position for the search, with the default being position 1.
String1 Required. Specifies the string in which to search.
String2 Required. Specifies the string to be searched for.
compare Optional. Specifies the type of string comparison to use. Possible values:

-1: Use the setting of Option Compare

 0: Binary comparison

 1: Textual comparison

 2: Database-specific comparison

 

Return Values

  • If string2 is not found within string1, the function returns 0.
  • If string1 is of zero length, the function returns 0.
  • If string1 is null, the function returns null.
  • If string2 is of zero length, the function returns the value of the start parameter.
  • If the start position is greater than the length of string2, the function returns 0.

Technical Details

Works in:

 From Access 2000