Query syntax of custom object records
You can use the Query custom object records API call to query custom object records. You can define your query through the q query parameter of this operation.
See the following query syntax for the q parameter.
Simple Query
Field Existence
Check existence of a field by querying with _exists_:[FieldName].
-
Search for custom fields data where the
titlefield has non-null value (the field exists and the value of it is not null)._exists_:title
Field Equality
Check whether the value of a field equals to a certain value by querying with [FieldName]:[ExpectedValue]
-
Search for custom fields data with field
statusisactive.status:active -
Search for custom fields data with field
authoridentical to phrase"john smith".author:"John Smith"
Ranges
Ranges can be specified for date and numeric fields. See the following statement syntax:
-
Less than:
[FieldName]:<[Upperbound] -
Less than or equal to:
[FieldName]:<=[Upperbound] -
Greater than:
[FieldName]:>[Lowerbound] -
Greater than or equal to:
[FieldName]:>=[Lowerbound]
Number
-
Search for custom fields data with field
ageless than5.age:<5
Date
When you query with ranges for date fields, you must use the \ (backslash) as an escape character for every colon (\:) in the date bounds as colon (:) is an operator in the query syntax.
-
Search for custom fields data with field
activeDateless than2018-01-01T00:00:00.001Z.activeDate:<2018-01-01T00\:00\:00.001Z -
Search for custom fields data with field
activeDateless than2018-01-01T00:00:00Z.activeDate:<2018-01-01T00\:00\:00Z -
Search for custom fields data with field
activeDateless than2018-01-01T00:00:00-08:00.activeDate:<2018-01-01T00\:00\:00-08\:00 -
Search for custom fields data with field
activeDateless than2018-01-01.activeDate:<2018-01-01 -
Search for custom fields data with field
activeDateless than2018-01(same as2018-01-01).activeDate:<2018-01 -
Search for custom fields data with field
activeDateless than2018(same as2018-01-01).activeDate:<2018 -
Search for custom fields data with field
activeDateless than1514764800000(2018-01-01in milliseconds).activeDate:<1514764800000
Note:
-
Range query by a number on a date field compares field values as a timestamp in milliseconds except that the number is a 4-digit number. In that case, the field values will be considered as the value of a year.
-
activeDate:<1will return custom fields data withactiveDateless than1970-01-01T00:00:00.001Z (0000000000001). -
activeDate:<2001will return custom fields data withactiveDateless than2001-01-01.
-
-
Range query by date only (without time) on date field with full date (with time) compares only their date part.
activeDate:>2018will not return custom fields data withactiveDatehas value2018-01-01T23:59:59Zsince their dates are equal. But it will return custom fields data withactiveDateis2018-01-02.
-
Range query by year only works the same as by the first day of that year. Range query by year-month works the same as by the first day of the month.
-
activeDate:>2018works the same asactiveDate:>2018-01-01. -
activeDate:>2018-05works the same asactiveDate:>2018-05-01.
-
-
Range query by full date (with time) on date field with date only (without time) will assume the time of the date field is
00:00:00.000Z.activeDate:<2018-01-01T00\:00\:00.001Zwill return custom fields data withactiveDatevalue as2018-01-01.
Complex Query Using Boolean Operators
Custom object query currently supports the AND (&&), OR (||)and NOT (!) operators. Note that the operators are case-sensitive. You must use uppercase.
AND
-
Search for custom fields data whose
statusisactiveandactiveDateis less than2018.status:active AND activeDate:<2018or
status:active && activeDate:<2018
OR
-
Search for custom fields data whose
statusisactiveoractiveDateis less than2018.status:active OR activeDate:<2018or
status:active || activeDate:<2018
NOT
-
Search for custom fields data whose
statusis missing orstatushas a null value.!_exists_:statusor
NOT _exists_:status -
Search for custom fields data whose
statusis notactive(statusis either missing or null).!status:activeor
NOT status:activeNote: To search for custom fields data where
statusexists and its value not equal toactive, use_exists_:status AND !status:active. -
Search for custom fields data with field
activeDateno less than2018(includingactiveDateis missing or null).!activeDate:<2018or
NOT activeDate:<2018Note: To search for custom fields data where
activeDateexists and its value is no less than2018, use_exists_:activeDate AND !activeDate:<2018.
Deal with the null value
The null value fields cannot be distinguished from the missing fields. Therefore, when querying by the existence of a field, it only returns the records that contain the field and the field value is not null. Query by the non-existence of one field will return the records that either miss this field or have a null value in this field.
