Mendix OQL (Object Query Language) is a relational query language just like SQL. The major advantage of OQL is that OQL uses entity and association names instead of the actual database table names.
Furthermore OQL can use the predefined relations (associations) to easily join objects without having to calculate which columns should be coupled. Despite these differences many SQL keywords also work in OQL.
Examples of OQL queries are:
SELECT Name FROM Sales.CustomerRetrieve the names of all customers.
SELECT FirstName FROM Sales.Customer WHERE Name = 'Jansen'Retrieve the first name of all customers with name ‘Jansen’.
SELECT AVG(TotalPrice) FROM Sales.Order WHERE IsPayed = 1Retrieve the average of the total prices of all paid orders.
An OQL query consists of a several components. Click on a component for more specific information.
||Determines which attributes of the object being queried are retrieved. Any functions that need to be performed on the retrieved data should also be defined here.|
||Designates the source entity from which the data will be retrieved.|
||Constrains the data being retrieved.|
|Group by clause(optional)||
||Group rows on the values of the specified attributes.|
|Order by clause(optional)||
||Sorts rows on the specified attributes.|
||Limits rows to a subset of the total amount.|