YQL - Filtering

April 10, 2026 ยท View on GitHub

The WHERE condition is shared among many YQL commands.

Syntax

[<item>] <operator> <item>

Items

An item can be:

WhatDescriptionExample
propertyRecord propertywhere price > 1000000
property<indexes>Record property access by index or key.where tags[name='Hi'] or tags[0-3] IN ('Hello') and employees IS NOT NULL
record attributeRecord attribute name with @ as prefixwhere @class = 'Profile'
any()Represents any property of the record. The condition is true if ANY of the properties matches the condition.where any() like 'L%'
all()Represents all the properties of the record. The condition is true if ALL the properties match the condition.where all() is null
functionsAny function among the available oneswhere distance(x, y, 52.20472, 0.14056 ) <= 30
$variableContext variable prefixed with $where $depth <= 3

Record attributes

NameDescriptionExample
@thisreturns the record itselfselect @this.toJSON() from Account
@ridreturns the Record ID in the form #<collection:position>. NOTE: using @rid in a WHERE condition slows down queries. It is much better to use the Record ID as the target. For example, instead of SELECT FROM Profile WHERE @rid = #10:44, use SELECT FROM #10:44.@rid = #11:0
@classreturns the class name@class = 'Profile'
@versionreturns the record version as integer. Version starts from 0. Can't be null@version > 0

Operators

Conditional Operators

Apply toOperatorDescriptionExample
any=Equal toname = 'Luke'
stringlikeSimilar to equals, but allows the wildcard '%' that means 'any'name like 'Luk%'
any<Less thanage < 40
any<=Less than or equal toage <= 40
any>Greater thanage > 40
any>=Greater than or equal toage >= 40
any<>Not equals (same of !=)age <> 40
anyBETWEENThe value is between a range. It's equivalent to <field> >= <from-value> AND <field> <= <to-value>price BETWEEN 10 and 30
anyISUsed to test if a value is NULLchildren is null
record, string (as class name)INSTANCEOFUsed to check if the record extends a class@this instanceof 'Customer' or @class instanceof 'Provider'
collectionINContains any of the elements listedname in ['European','Asiatic']
collectionCONTAINSTrue if the collection contains at least one element that satisfies the next condition. Condition can be a single item: in this case the behavior is like the IN operatorchildren contains (name = 'Luke') - map.values() contains (name = 'Luke')
collectionCONTAINSALLTrue if all the elements of the collection satisfy the next conditionchildren containsAll (name = 'Luke')
collectionCONTAINSANYTrue if any of the elements of the collection satisfy the next conditionchildren containsAny (name = 'Luke')
mapCONTAINSKEYTrue if the map contains at least one key equal to the requested. You can also use map.keys() CONTAINS in place of itconnections containsKey 'Luke'
mapCONTAINSVALUETrue if the map contains at least one value equal to the requested. You can also use map.values() CONTAINS in place of itconnections containsValue #10:3
stringCONTAINSTEXTChecks whether the string contains the given substring.text containsText 'vika'
stringMATCHESMatches the string using a Regular Expressiontext matches '.[A-Z0-9.%+-]+@[A-Z0-9.-]+[.][A-Z]{2,4}.'

Logical Operators

OperatorDescriptionExample
ANDTrue if both the conditions are truename = 'Luke' and surname like 'Sky%'
ORTrue if at least one of the conditions is truename = 'Luke' or surname like 'Sky%'
NOTTrue if the condition is false. NOT requires parentheses around the condition to negate.not ( name = 'Luke')

Mathematics Operators

Apply toOperatorDescriptionExample
Numbers+Plusage + 34
Numbers-Minussalary - 34
Numbers*Multiplyfactor * 1.3
Numbers/Dividetotal / 12
Numbers%Modtotal % 3

YouTrackDB supports the eval() function to execute complex operations. Example:

select eval( "amount * 120 / 100 - discount" ) as finalPrice from Order

Methods

Also called "Property Operators", these are documented on a separate page.

Functions

All the YQL functions are documented on a separate page.

Variables

YouTrackDB supports variables managed in the context of the command/query. By default, some variables are created. Below is the table with the available variables:

NameDescriptionCommand(s)
$parentGet the parent context from a sub-query. Example: select from V let $type = ( traverse * from $parent.$current.children )SELECT
$currentCurrent record to use in sub-queries to refer from the parent's variableSELECT

To set custom variables, use the LET keyword.