Don't forget to check out our JSON RESTful APIs, they can help you utilize and extend Quickbase with ease.
The query parameter determines which records are returned. You can build a new query string inside the <query></query> tag or you can choose to reference a saved query string using the <qid> or <qname> tags.
Building the query string
When you build a query, you must build at least one query string. A query string is composed of:
-
a field ID (fid)
-
an uppercase comparison operator
-
the value to be compared against (see the table below for a list of available operators).
You should separate each of these query string components using a period and enclose the entire query string in curly braces, as shown below:
{'fid'.operator.'matching_value'}
Example:
<query>{'5'.CT.'Ragnar Lodbrok'}</query>
This example specifies that Quickbase should return all records where the “fid 5” field contains the value “Ragnar Lodbrok.”
Grouping multiple query strings
You can group several of query strings together, separating the query strings with the AND or OR operators, as shown here:
Example:
<query>{'5'.CT.'Ragnar Lodbrok'}AND{'7'.CT.'Acquisitions'}</query>
The next example illustrates how to group query strings together when using a URL:
Example:
&query={'5'.CT.'Ragnar Lodbrok'}AND{'7'.CT.'Acquisitions'}
Note: You can obtain the fids for a table by calling API_GetSchema, or from any call to API_DoQuery that sets the <fmt> parameter to structured.
Query string comparison operators
Note: Query string comparison operators must be in uppercase.
Comparison Operator |
Description |
CT |
Contains |
XCT |
Does not contain |
EX |
Is |
TV |
True Value (compares against the underlying foreign key or record ID stored in relationship fields. Also used for queries on user fields. |
XEX |
Is not |
SW |
Starts with |
XSW |
Does not start with |
BF |
Is before |
OBF |
Is on or before |
AF |
Is after |
OAF |
Is on or after |
LT |
Is less than |
LTE |
Is less than or equal to |
GT |
Is greater than |
GTE |
Is greater than or equal to |
Handling Special Characters for a Query Field Values
If you are searching for a value that includes special characters, be sure to enclose the matching value in quotes. For example, if you are searching for this value:
"Joe B. Briggs"
...you should be sure to enclose the entire string in double quotes, as follows:
""Joe B. Briggs""
Querying on Dates and Times
You can query on dates (using the date format set in the app) or on times in milliseconds, but you cannot query on times in Date/Time fields.
Special Matching Values in a Query String
Certain field types use special values with a given comparison operator. For example, you may want to query on a checkbox field. You may want all records where a checkbox is either checked or not. In cases like this, you can use special matching values in your query string to return records with the value you want.
Field Type |
Matching Value |
Description |
Checkbox |
1 or 0 |
Used to filter records by the checked or unchecked status of the checkbox. 0 = Is unchecked |
Date and Date/Time |
today or <num> days ago or -<num> days ago or the actual date, using the correct date format for the app |
Filter records by a date criteria. today = Today’s date. Example:{'13'.EX.'today'} Number of days in the past as measured by the current date. Example: {'13'.EX.'2 days ago'} Number of days in the future as measured from the current date, with a negative sign in front of the number to specify that the date is in the future. Example: for tomorrow’s date, {'13'.EX.'-1 days ago'} A specific date. For example: {'13'.EX.'05-18-2008'} |
user |
_curuser_ |
Used to get records owned or created by the current user. For example, {'20'.TV.'_curuser_'} |
Referencing a Common Report
In the Quickbase UI, a user can customize a report and save it as a common report, which will then be available as a saved query. Each saved query has an ID (qid) and a user-supplied name (qname). Creating a saved query is an easy and quick way to construct a query, compared to building the query string yourself.
To use a saved query, you refer to it by its qid (e.g., <qid>3</qid>) or by the name you gave it when you saved it (e.g., <qname>My Custom View</qname>. For the qname value, do not replace blanks spaces with underscore.
You can use API_DoQuery to get the qid and qname of common reports. If you use the <fmt> parameter, Quickbase returns a list of all saved queries inside a <queries> aggregate, including their qid and qnames. (You can also use API_GetSchema to get the qid or qname of a saved query).
Quickbase tables have two default saved queries: List All, and List Changes.