Filtering with WHERE
Combine conditions with AND, OR and NOT, compare numbers and strings, match lists, ranges and regular expressions.
The WHERE clause is a boolean expression over the features of an object. The previous lesson used one comparison; this one shows how comparisons combine and what they can compare.
Combining conditions#
AND, OR and NOT work as you expect, and parentheses group. AND binds tighter than OR, so write the parentheses when an OR is involved:
GET qid, attribute.Name, attribute.LongName
WHERE type = IFCSPACE AND (attribute.LongName = "keuken" OR attribute.LongName = "badkamer")NOT negates the condition after it: type = IFCDOOR AND NOT attribute.Name CONTAINS "stelkozijn" gives the doors whose name does not contain that word. Note that NOT is the complement, so it also keeps objects that have no name at all.
Comparing values#
Numbers take =, !=, <, <=, >, >=, IN (…) and BETWEEN a AND b (inclusive on both ends). A numeric literal may carry a unit, > 2.5 m, which the next lessons use on quantities. Strings take =, != and IN ("a", "b"), plus four comparators of their own:
| Comparator | Matches when the value … |
|---|---|
CONTAINS "x" |
contains x anywhere |
STARTS_WITH "x" |
begins with x |
ENDS_WITH "x" |
ends with x |
MATCHES_REGEX "^D[0-9][LR]$" |
matches the regular expression as a whole |
LENGTH > 5 |
is longer than 5 characters (any of = != < <= > >=) |
String comparisons ignore case. Put CS in front of the comparator when case matters: attribute.Name CS = "D1L", attribute.Name CS STARTS_WITH "D". The regular expression is Java syntax and must match the whole value: MATCHES_REGEX "D[0-9]" does not match D1L, MATCHES_REGEX "D[0-9].*" does. All comparators are listed in WHERE.
Missing values#
A feature written without a comparator is a condition of its own and means "has a value": type = IFCDOOR AND attribute.Description gives the doors that carry a description — none in the demo model, as it happens. The opposite is NOT in front of it: type = IFCDOOR AND NOT attribute.Description gives all 205 doors, because none of them has a description.
Write "has no value" as NOT <feature>, not as <feature> = null. The grammar accepts attribute.Description = null, but on the demo model it matches nothing at all: a comparison needs a value on the left, and an object without the feature never gets that far. Checked on 2026-09-10 against Schependomlaan.
The distinction matters with != too: attribute.Name != "D1L" only matches objects that have a name.
Your turn#
GET qid, attribute.Name WHERE type = IFCWALLHints
- Add a second condition with AND.
- STARTS_WITH compares the beginning of a string.
Show solution
GET qid, attribute.Name WHERE type = IFCWALL AND attribute.Name STARTS_WITH "binnen"GET qid, attribute.Name WHERE type = IFCWALL AND attribute.Name MATCHES_REGEX "binnen.*"GET qid, attribute.Name WHERE type = IFCDOOR AND attribute.Name = "D1L"Hints
- Three ORs work, but IN takes a list of strings.
- Strings are double-quoted and separated by commas.
Show solution
GET qid, attribute.Name WHERE type = IFCDOOR AND attribute.Name IN ("D1L", "D1R", "D5L")GET qid, attribute.Name WHERE type = IFCDOOR AND (attribute.Name = "D1L" OR attribute.Name = "D1R" OR attribute.Name = "D5L")GET qid, attribute.Name, attribute.LongName WHERE type = IFCSPACEHints
- Two conditions on LongName, combined with OR.
- The OR needs parentheses next to the AND on type.
- "slaapkamer 1" and "slaapkamer 2" both contain "slaapkamer".
Show solution
GET qid, attribute.Name, attribute.LongName WHERE type = IFCSPACE AND (attribute.LongName CONTAINS "slaapkamer" OR attribute.LongName = "woonkamer")GET qid, attribute.Name, attribute.LongName WHERE type = IFCSPACE AND (attribute.LongName = "woonkamer" OR attribute.LongName CONTAINS "slaapkamer")The result of that round is shown as JSON rather than as a table: this is exactly what an SDK hands you. Every leaf is an object with the value and its metadata, and a feature an object has no value for is simply absent — a space without a LongName has no LongName key.
GET qid, attribute.Name WHERE type = IFCDOOR AND attribute.Name CONTAINS "D"Hints
- CONTAINS finds a D anywhere in the name; the goal is a shape the whole name has to have.
- STARTS_WITH cannot express "one digit"; a regular expression can.
- MATCHES_REGEX must match the whole name, so no ^ and $ are needed.
- [0-9] is one digit, [LR] is one of the two letters.
Show solution
GET qid, attribute.Name WHERE type = IFCDOOR AND attribute.Name MATCHES_REGEX "D[0-9][LR]"GET qid, attribute.Name WHERE type = IFCDOOR AND attribute.Name MATCHES_REGEX "^D[0-9][LR]$"You can now#
- Combine conditions with
AND,OR,NOTand parentheses. - Compare strings with
CONTAINS,STARTS_WITH,ENDS_WITHandMATCHES_REGEX, case-sensitive when you addCS. - Test a list with
INand a range withBETWEEN. - Tell "has a value" from "is null".
Next: Properties and quantities, where the conditions reach beyond the IFC attributes.