Operators for Mergado Query Language#

List of operators in MQL#

This overview explains all operators you can use in Mergado Query Language (MQL) – a language for creating conditions in product queries. It will help you better understand how MQL works and how to formulate rules for selecting data precisely. With the correct use of operators, you will be able to create accurate, efficient, and well-organized queries.

Operator Overview#

Operator Meaning
CONTAINS contains text
NOT CONTAINS does not contain text
= equals
!= does not equal
~ contains regular expression
!~ does not contain regular expression
<= is less than or equal to*
>= is greater than or equal to*
< is less than*
> is greater than*
IN is included in a list
NOT IN is not included in a list
OR logical “or” expression
AND logical “and” expression
SORT BY sorts by element name

*Used only for numeric values.

Modifiers for SORT BY#

Modifier Meaning
DESC sorts in descending order
ASC sorts in ascending order
AS NATURAL sorts in natural order

These modifiers are used together with the SORT BY operator and determine how results are sorted.

How to Write Conditions Correctly#

Conditions in MQL always follow this pattern:

[<element>] <operator> <value>

Example:

[PRICE] >= 100

Writing Rules#

  • Values do not need quotes if they contain only a single alphanumeric word or number. E.g., [CATEGORY] = Electronics
  • Element names should be enclosed in square brackets if they contain non-alphanumeric characters: [PARAM | color] = "blue"
  • Text values and regular expressions should be written in straight quotes " ", not typographic quotes.
  • Recommendation: always use square brackets. This way, Mergado will offer a list of available elements as you type your query.

Tips for Efficient Work#

  • Combine the AND and OR operators to create complex queries.
  • Use SORT BY for clear result ordering – for example, by price or name.
  • If you are unsure which operator to use, start with CONTAINS – it easily verifies whether an element contains the desired text.
  • For precise pattern matching, use regular expressions (~ and !~).

FAQ#

What is the basic format of an MQL condition?#

A condition follows the pattern [<element>] <operator> <value>.

When do I need quotes around a value?#

Use them when the value contains spaces or special characters. Single-word alphanumeric values and numbers do not need them.

What is the difference between CONTAINS and ~?#

CONTAINS searches for exact text, while ~ allows searching using a regular expression (pattern).

Can I combine multiple conditions?#

Yes, you can join multiple expressions into one query using AND and OR.

What is SORT BY used for, and what about its modifiers?#

SORT BY determines which element results are sorted by. The modifiers ASC, DESC, and AS NATURAL set the sort order.

🇨🇿 🇬🇧 🇩🇪 🇭🇺