- You must include a space before and after the operator in all where expressions.
To find objects where a particular property is blank, use a
double quote
(no space). For example, if you want find objects that do not contain a description, use (description ~~ “”). For Boolean attributes, searching on “” results in finding objects where the value for the attribute is False, even if the default is True. (Boolean attributes, are either True or False, as opposed to Boolean expressions, which can be True, False or Unknown.)
-
To find objects where a particular property is non-blank, use a
double asterisk
. For example, if you want be sure that all objects in the result of your query contain a description, use (description ~~ “**”).
-
In complicated expressions, particularly those that use
!
or not
, use parentheses to clearly state your intent. For example, in the following, the !
is applied to the entire clause:
!relationship[Categorize] == True || relationship[Categorize].from.id
=="43482.46832.5291.38424
To apply the ! to only the portion before the OR (||), change it to:
(!relationship[Categorize] == True) || relationship[Categorize].from.id
== 4448.10921.47699.5768
-
The datatype of relational expressions (>,<,==) in where clauses is determined by the
left operand. In the following example, the left operand is a hard coded string:
temp query bus "Engineering Drawing" * * where ' "Jul 30, 2001 00:00:00 AM EDT" > originated ';
What appears to be a date (Jul 30...) is seen as a string, and so it does not find June originated dates because June alphabetically comes after July. For the inequality to do a date comparison, put originated on the left to establish the data type for the expression:
where 'originated > "Jul 30, 2001 00:00:00 EDT"
-
Always enclose the entirety of the
where
clause in SINGLE quotes. If the expression is not enclosed, MQL will not read it as a single value. Most query expressions contain multiple values and spaces. Therefore quotes are necessary to determine the boundaries of the expression. -
Strings in square brackets can have spaces—the square brackets delimit them, but any other strings with spaces should be enclosed in DOUBLE quotes.
-
When using
where
clauses with
expand bus
, you must always insert
select bus
or
select rel
before a
where
clause. For more information, see SELECT_ BO and SELECT_REL Clauses for the Expand Businessobject Command.
The syntax of a query command affects the execution of the query. Occasionally, there are core changes that handle commands slightly differently, or might add a few new options to a command, for additional functionality. For example, the change from version 9521 to version 9601 resulted in the handling of the
relationship
keyword differently within a
where
clause. (The
relationship
keyword can still be used in a
select
clause without adversely affecting performance.) This caused queries that ran fast under the older version to run much more slowly. The following query is an example:
temp query bus myType * * where '(relationship[myRelationship].attribute[myAttribute] ...)';
In the latest version of 3DSpace, the solution is to get rid of the
relationship
keyword and instead create separate clauses with "from" and "to" in them:
temp query bus myType * * where '(from[myRelationship].attribute[myAttribute] ...)
Or
(to[myRelationship].attribute[myAttribute] ...)';