MS SQL Server: Filter Using Comparisons
Introduction
Comparison operators are used to compare values of the same type. For example, to compare two numbers, two strings, two dates, etc.
Equality operators (_eq, _neq)
The _eq (equal to) or the _neq (not equal to) operators are compatible with any MS SQL Server type (like Integer,
Float, Double, Text, Boolean, Date/Time/Timestamp, etc.).
The following are examples of using the equality operators on different types.
Example: Integer (works with Double, Float, Int, etc.)
Fetch data about an author whose id (an integer field) is equal to 3:
Example: String or Text
Fetch a list of authors with name (a text field) as "Sidney":
Example: Boolean
Fetch a list of articles that have not been published (is_published is a boolean field):
Example: Date (works with Time, Timezone, etc.)
Fetch a list of articles that were published on a certain date (published_on is a Date field):
Greater than or less than operators (_gt, _lt, _gte, _lte)
The _gt (greater than), _lt (less than), _gte (greater than or equal to), _lte (less than or equal to) operators
are compatible with any MS SQL Server type (like Integer, Float, Double, Text, Boolean,
Date/Time/Timestamp, etc.).
The following are examples of using these operators on different types:
Example: Integer (works with Double, Float, etc.)
Fetch a list of articles rated 4 or more (rating is an integer field):
Example: String or Text
Fetch a list of authors whose names begin with M or any letter that follows M (essentially, a filter based on a dictionary sort):
Example: Date (works with Time, Timezone, etc.)
Fetch a list of articles that were published on or after date "01/01/2018":
List based search operators (_in, _nin)
The _in (in a list) and _nin (not in list) operators are used to compare field values to a list of values. They are
compatible with any MS SQL Server type (like Integer, Float, Double, Text, Boolean, Date/Time/Timestamp,
etc.).
The following are examples of using these operators on different types:
Example: Integer (works with Double, Float, etc.)
Fetch a list of articles rated 1, 3 or 5:
Example: String or Text
Fetch a list of those authors whose names are NOT part of a list:
Filter or check for null values (_is_null)
Checking for null values can be achieved using the _is_null operator.
Example: Filter null values in a field
Fetch a list of articles that have a value in the published_on field: