MS Access StrComp() Function

Example

Compare two strings:

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

Definition and Usage

The StrComp() function compares two strings.

The result is returned as an integer based on the comparison:

  • If string1 = string2, this function returns 0
  • If string1 < string2, this function returns -1
  • If string1 > string2, this function returns 1
  • If string1 or string2 is null, this function returns null

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

Technical Details

Works in: From 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 »

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.