MS Access StrComp() Function
THE WORLD'S LARGEST WEB DEVELOPER SITE

MS Access StrComp() Function

❮ MS Access Functions

Example

Compare two strings:

SELECT StrComp("SQL Tutorial", "SQL Tutorial") AS CompString;
Try it Yourself »

Definition and Usage

The StrComp() function returns an integer value representing the result of a string comparison.

Syntax

StrComp(string1, string2, compare)

Parameter Values

Parameter Description
string1 and string2 Required. The two strings to compare
compare Optional. The type of comparison to perform.

Possible values:
-1: Uses option compare
0: Binary comparison
1: Textual comparison
2: Comparison based on your database

Note

  • If string1 is equal to string2, the StrComp function will return 0
  • If string1 is less than string2, the StrComp function will return -1
  • If string1 is greater than string2, the StrComp function will return 1
  • If either string1 or string2 is null, the StrComp function will return null

Technical Details

Works in: Access 2016, Access 2013, Access 2010, Access 2007, Access 2003, Access XP, Access 2000

More Examples

Example

Compare two strings:

SELECT StrComp("SQL Tutorial", "SQL") AS CompString;
Try it Yourself »

Example

Compare two strings:

SELECT StrComp("SQL", "SQL Tutorial") AS CompString;
Try it Yourself »

❮ MS Access Functions