A query typically includes the following parameters:
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 (see the table below for a list of available operators).
the value to be compared against
You should separate each of these query string components using a period and enclose the entire query string in curly braces, as shown below:
This example specifies that Quick Base 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:
The next example illustrates how to group query strings together when using a URL:
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.”
Note: Query string comparison operators must be in uppercase.
(Do not use this operator with list-user fields; instead, use HAS.)
Does not contain
(Do not use this operator with list-user fields; instead, use XHAS.)
Contains a specific set of users. Used with list-user fields only.
For each user you are trying to find, you must enter the user's ID, user name, or email address. You can also enter placeholder names. Be sure to surround placeholder names with double quotes.
The query parameter must be surrounded by single quotes.
Separate users in the list using a semi-colon.
Does not contain a specific set of users. Used with list-user fields only.
The query parameter must contain the user's ID, email address, or user name. You can also specify a placeholder name. Placeholder names must be enclosed in double quotes.
The entire query parameter must be surrounded by single quotes. Separate users in the list using semi-colons.
Note that a matching record must contain all users you specify. This query:
...specifies that you want to see records that do not contain BOTH of these users. Therefore, the query will return records that contain either one or neither, but not both, of these users.
True Value (compares against the underlying foreign key or record ID stored in relationship fields). Also used for queries on User fields.
Not True Value (compares against the underlying foreign key or record ID stored in relationship fields). Also used for queries on User fields.
Does not start with
Is on or before a specific date
Is after a specific date
Is on or after a specific date
Is in range. Use this operator with date fields, to determine whether a particular date falls within particular date range relative to the current date. Learn more about relative date ranges.
Is not in range. Use this operator with date fields, to determine whether a particular date falls within a particular date range relative to the current date. Learn more about relative date ranges.
Is less than
Is less than or equal to
Is greater than
Is greater than or equal to
To query a particular field and exclude a string:
To query any field for a date:
To combine multiple query strings:
To query for records owned by the current user:
To query for records modified by the current user:
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 (yyyy-MM-dd) or on times in milliseconds, but you cannot query on date-time values in the standard "yyyy-MM-dd hh:mm:ss" format.
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.
1 or 0
Date and Date/Time
<num> days ago
-<num> days ago
Referencing a Common Report
In the Quick Base 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.,
or by the name you gave it when you saved it (e.g.,
View</qname>. For the qname value, do not replace blanks spaces
You can use API_DoQuery to get the qid and qname of common reports. If you use the fmt parameter, Quick Base 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).
Quick Base tables have two default saved queries: List All, and List Changes.
The clist specifies which columns will be included in each returned record and how they are ordered in the returned record aggregate.
...where each number is the fid of the field (column) you want returned, with a period separating the fids. The columns will be listed in the returned record in the same order as they appear in the clist. If you don’t specify a clist, Quick Base returns your table’s default columns and order.
If no column list parameter is supplied, the default report layout and field order is used.
To change the default field order, see the Quick Base online help:
Changing the default field order in a table.
Changing the default field order on a form.
How to Return ALL of the columns
Specify the value a in the clist param to specify that all columns should be returned.
The sort list parameter determines the order in which the returned records are displayed as follows:
The following slist parameter sorts all records by the field whose fid is 7.
You can specify a secondary sort by including another fid in the string (separating each fid with a period)
If you don’t specify the sort list, the default sort specified on the Report Layout page determines the order in which records are displayed.
You use the options parameter to further control the return of records. You can use any or all of the options, separating the options with a period.
num-n--specifies a maximum of n records in the return
onlynew--returns only those records marked with new or updated flags
skp-n--skips the first n records returned by the query
sortorder-A--specifies an ascending order
sortorder-D--specifies a descending sorts.
This tells Quick Base to skip the first 15 records the query would normally return and give you the next 15 records. It also specifies that all sorts should be in ascending order.
If you don’t supply the options parameter, the records are sorted in ascending order and the number of records returned will be the same number as the Quick Base is set to return.
About the Sort Order Option
You can apply a different sort order to different returned columns in the clist by supplying several period-delimited sortorder parameters:
This example sorts the first column in the clist in ascending order, the second and third columns in descending order, and the fourth column in ascending order.
The onlynew parameter produces a different result for each user that is logged into Quick Base: it won’t work with the Quick Base anonymous user.
Use the fmt parameter to specify structured returns. If you don't specify this parameter, query returns are not structured; Quick Base returns the table name, any DBVars, and the record data with the fields you specified, all with the field names, like this:
<business_phone_number>(123) 103-1234 x12345</business_phone_number>
In contrast, if you specify structured returns using the fmt parameter, Quick Base returns field IDs (fids) instead of field names. Quick Base will also return URLs of file attachments. (For an alternative way to download files without this URL, see Downloading Files.) Using structured format, Quick Base also returns:
a list of all saved queries you can use
field properties and the default values for all the fields you asked for in your query.
When you use structured format, the field data is presented in a more compact form so you can immediately spot the fid and the actual field value.
<f id="6">(650) 123-1234</f>
<f id="22"> Model_T.jpg
In the example, target_domain is the domain against which you are invoking this call, for example, quickbase.com. Read about this notation.
Did this help you? Give us a rating:
© 1999-2020 QuickBase, Inc. All rights reserved. Legal Notices.