Newer Version Available

This content describes an older version of this product. View Latest

SOQL Typographical Conventions

SOQL topics use custom typographical conventions.
Convention Description
SELECT Name FROM Account Courier font indicates items that you should type as shown. In a syntax statement, Courier font also indicates items that you should type as shown, except for curly braces, square brackets, ellipsis, and other typographical markers explained in this table.
SELECT fieldname FROM objectname Italics represent a variable or placeholder. You supply the actual value.
{} Curly braces group elements to remove ambiguity. For example, in the clause UPDATE {TRACKING|VIEWSTAT}[,...], the curly braces indicate that the pipe shows a choice between TRACKING and VIEWSTAT after UPDATE, rather than a choice between UPDATE TRACKING and VIEWSTAT.
| The pipe character separates alternate elements. For example, in the clause UPDATE {TRACKING|VIEWSTAT}[,...], the | character indicates that you can use either TRACKING or VIEWSTAT after UPDATE.
[] Square brackets indicate an optional element. For example, [LIMIT rows] means that you can specify zero or one LIMIT clause. Don’t type square brackets as part of a SOQL command. Nested square brackets indicate elements that are optional and can only be used if the parent optional element is present. For example, in the clause [ORDER BY fieldOrderByList [ASC | DESC] [NULLS {FIRST | LAST}]] , ASC, DESC, or the NULLS clause cannot be used without the ORDER BY clause.
[...] and [,...] Square brackets containing an ellipsis indicate that the preceding element can be repeated up to the limit for the element. If a comma is also present, the repeated elements must be separated by commas. If the element is a list of choices grouped with curly braces, you can use items from the list in any order. For example, in the clause UPDATE {TRACKING|VIEWSTAT}[,...], the [,...] indicates that you can use TRACKING, VIEWSTAT, or both:
1UPDATE TRACKING
1UPDATE VIEWSTAT
1UPDATE TRACKING, VIEWSTAT

Alias Notation

You can use alias notation in SELECT queries:
1SELECT count()
2FROM Contact c, c.Account a
3WHERE a.name = 'MyriadPubs'

To establish the alias, first identify the object, in this example a contact, and then specify the alias, in this case “c.” For the rest of the SELECT statement, you can use the alias in place of the object or field name.

The following are SOQL keywords that can’t be used as alias names: AND, ASC, DESC, EXCLUDES, FIRST, FROM, GROUP, HAVING, IN, INCLUDES, LAST, LIKE, LIMIT, NOT, NULL, NULLS, OR, SELECT, WHERE, WITH