@SELECT sql_query

Binds the variable to a database query that returns a recordset. Where sql_query is the actual database query. The return value is a recordset.

Example: We can use the @SELECT command the same way we would use a regular SQL SELECT statement:

Note: When using the CMS database tables you can use the [PREFIX] tag before the table name. This will append the database and table prefix to the table name. You can also use manually apply the table prefix to the table name if it's known. For example, modx_site_content, where modx_ is the table prefix used in this example.

The result is a simple database listing of the first 10 documents.

You can also use the @SELECT command to provide your document editors with a dynamic list of options from a DropDown Menu.


@SELECT color_name, color_value FROM colors

When the user edits the document he/she will see a list of color options from which to choose.

Suggest an edit to this page.