Skip to content

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.

SELECT {fields} FROM {query target}

You 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.

These options are used in the FROM clause to modify which records or versions are included in your query results.

NameTargetDescriptionAPI Version
ALLVERSIONSDocumentsRetrieve fields from all document versions.v8.0+
LATESTVERSIONDocumentsRetrieve fields from the latest version of all documents.v8.0+
FAVORITESBothFilter results to records marked as favorites by the currently authenticated user.v22.2+
RECENTBothFilter results to the 20 most recently viewed documents or object records.v22.2+

These functions are used in the SELECT clause to control how field values are returned in the query response.

NameTargetDescriptionAPI Version
TONAME()DocumentsReturn the document field name instead of the label.v20.3+
TOLABEL()ObjectsReturn the object field label instead of the name.v24.1+
TODISPLAYFORMAT()ObjectsReturn an object field’s formatted value instead of the raw value.v23.2+
LONGTEXT()BothRetrieve the full value of Long Text fields.v17.1+
RICHTEXT()BothRetrieve the full value (with HTML markup) of Rich Text fields.v21.1+
TRIM()BothRetrieve 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.

NameDescriptionAPI 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+

The following are examples of queries using SELECT and FROM.

The 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 documents

Response: 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" } ] }