MQL reference
MQL is SQL-like in its syntax, but supports a rather specific subset of SQL functions and, we hope, is much simpler. While you should be inspired to use your knowledge of SQL to try things in MQL, please do not assume that anything that works in SQL will work in MQL. For example, you cannot do a JOIN using MQL.
SELECT
Many of the macros allow/require you to specify the set of cards you wish to render using a MQL SELECT statement. A MQL SELECT is very similar to a SQL SELECT except that you are selecting card properties rather than database columns.
Conditions / WHERE
A WHERE clause can be added to any SELECT statement to restrict the set of cards. Where a macro calls for only a conditions clause, the inclusion of the WHERE keyword is optional.
In a condition clause the following operators are supported:
* =
* !=
* NOT
* >
* >=
* <
* <=
* AND
* OR
* ( ... )
The following syntax for checking that the value of a property has not been set
- WHERE NOT Status IS NULL
- WHERE Status IS NULL
- WHERE NOT Status = NULL
- WHERE Status = NULL
- WHERE Status != NULL
Aggregation
Where aggregation functions (AVERAGE, COUNT, SUM) are supported you can select an aggregation function as one of your result set columns. If you are selecting only a single column and it is an aggregation, you must also specify a GROUP BY clause.
If your database supports aggregation functions other than AVERAGE, COUNT, and SUM you may try them, but we cannot guarantee that they will work.
Quoting property names
Property names can always be quotes using single quotes. Property names containing spaces must always be quoted with single quotes.
Card type
Card types work exactly like any other list property in MQL. The property name is Type. Certain operations, like lesser than and greater than, that do not make sense for a card type are not supported.
List properties
{{ table query: SELECT number, name, status WHERE Type=Feature AND Risk < Medium }}
User properties
When using user properties in MQL, the user's login should be used as the value. Operations such as greater than and lesser than are not supported for user property values. In addition, to specify a value representing the currently logged in user, use the CURRENT USER keywords.
{{ table query: SELECT number, name, status WHERE Owner = CURRENT USER }}
Date properties
All properties, except numeric ones can be compared to a date. Mingle is lenient in interpreting dates and does not restrict you to the project's date format. The newly introduced date properties will behave the same way. Operators such as greater than and less than work as expected in the context of dates. In addition to this, to specify a value representing the current day in the project time zone, use the TODAY keyword. Similar to user properties, you can also use special keywords like IS TODAY and IS NOT TODAY to express your intent more clearly.
{{table query: SELECT number, name WHERE 'Completed On' IS TODAY }}
The project time zone is used to determine TODAY.
Free text properties
Free text properties can be used in a manner similar to list properties except there is no obvious concept of ordering in a text property. If a free text property is used to store purely numeric values, you can use the property in aggregate operations like AVERAGE and SUM as well. Default comparison for text property values is alphabetic. On the other hand, default sort order is numeric if the column contains purely numeric values and you are doing a numeric comparison.