Start a new topic
Answered

"Any...has" function in SemQL

Could someone describe how SemQL function any...has(something=something) works? What is difference when has is replaced with have? What are the supported parameters in this function? What else should I know when using this any..has(..) function?


Best Answer

The any/all SemQL syntax allows you to query child entities records.

any/all <child_entity_role> have/has ( <condition_on_child_entity> )

"any" means at least one record from the child entity follows the condition.

"all" means all records from the child entity follow the condition.

"has" and "have" behave exactly the same, they exist only for the expression to be grammatically correct, but you may use one or the other interchangeably.

A good tip is to use 1=1 as a condition when the goal is just to check child records existence without any other specific criteria. For example, either of these will return true if at least one contact exists for the parent record:

  • ANY Contact HAS (1=1)
  • ANY Contact HAS ( ID IS NOT NULL )

More details and examples in this documentation.

1 Comment

Answer

The any/all SemQL syntax allows you to query child entities records.

any/all <child_entity_role> have/has ( <condition_on_child_entity> )

"any" means at least one record from the child entity follows the condition.

"all" means all records from the child entity follow the condition.

"has" and "have" behave exactly the same, they exist only for the expression to be grammatically correct, but you may use one or the other interchangeably.

A good tip is to use 1=1 as a condition when the goal is just to check child records existence without any other specific criteria. For example, either of these will return true if at least one contact exists for the parent record:

  • ANY Contact HAS (1=1)
  • ANY Contact HAS ( ID IS NOT NULL )

More details and examples in this documentation.

Login to post a comment