SELECT & FROM
The SELECT and FROM clauses form the basis of most VQL queries and allow you to retrieve field values from Vault. The SELECT clause specifies the fields to retrieve. The FROM clause indicates the query target from which to retrieve those fields.
You must use the FROM clause to specify the query target.
Syntax
Section link for SyntaxSELECT {fields}
FROM {query target}Functions & Options
Section link for Functions & OptionsYou can use the following functions and query target options in the SELECT and FROM clauses. For a full list of all available functions, see the VQL Functions & Options reference.
Refining Query Scope (FROM)
Section link for Refining Query Scope (FROM)These options are used in the FROM clause to modify which records or versions are included in your query results.
| Name | Target | Description | API Version |
|---|---|---|---|
ALLVERSIONS | Documents | Retrieve fields from all document versions. | v8.0+ |
LATESTVERSION | Documents | Retrieve fields from the latest version of all documents. | v8.0+ |
FAVORITES | Both | Filter results to records marked as favorites by the currently authenticated user. | v22.2+ |
RECENT | Both | Filter results to the 20 most recently viewed documents or object records. | v22.2+ |
Formatting Field Outputs (SELECT)
Section link for Formatting Field Outputs (SELECT)These functions are used in the SELECT clause to control how field values are returned in the query response.
| Name | Target | Description | API Version |
|---|---|---|---|
TONAME() | Documents | Return the document field name instead of the label. | v20.3+ |
TOLABEL() | Objects | Return the object field label instead of the name. | v24.1+ |
TODISPLAYFORMAT() | Objects | Return an object field’s formatted value instead of the raw value. | v23.2+ |
LONGTEXT() | Both | Retrieve the full value of Long Text fields. | v17.1+ |
RICHTEXT() | Both | Retrieve the full value (with HTML markup) of Rich Text fields. | v21.1+ |
TRIM() | Both | Retrieve a picklist name without the namespace suffix. | v25.1+ |
Retrieving Attachment Metadata (SELECT)
Section link for Retrieving Attachment Metadata (SELECT)These specialized functions are used to retrieve metadata from Attachment fields.
| Name | Description | API Version |
|---|---|---|
FILENAME() | Use the file name of an Attachment field file instead of the file handle. | v24.3+ |
FILESIZE() | Retrieve the size of the file in bytes. | v24.3+ |
MIMETYPE() | Retrieve the MIME type (e.g., application/pdf). | v24.3+ |
MD5CHECKSUM() | Retrieve the MD5 hash of the file. | v24.3+ |
Query Examples
Section link for Query ExamplesThe following are examples of queries using SELECT and FROM.
Query: Retrieving All Documents
Section link for Query: Retrieving All DocumentsThe following query returns the ID, name, and status of the latest version of all documents in a Vault:
SELECT id, name__v, status__v
FROM documentsResponse: Retrieving All Documents
Section link for Response: Retrieving All Documents{
"responseStatus": "SUCCESS",
"responseDetails": {
"pagesize": 1000,
"pageoffset": 0,
"size": 54,
"total": 54
},
"data": [
{
"id": 68,
"name__v": "Cholecap Akathisia Temporally associated with Adult Major Depressive Disorder",
"status__v": "Draft"
},
{
"id": 65,
"name__v": "Gludacta Package Brochure",
"status__v": "Approved"
},
{
"id": 64,
"name__v": "Gludacta Logo Light",
"status__v": "Approved"
}
]
}