logo


58.1.5 Query Tutorial: Query Order and Set Theory


The answer to the “Or” puzzle lies in Set Theory. STATIC relies heavily on mathematical Set Theory. Graphically, we could represent the three sets as:

 

Query Tutorial: Query Order and Set Theory

Set Theory: A Graphical Explanation

Let's use these three graphical representations to understand how 4D interprets the query conjunctions AND, OR, and EXCEPT.

AND = Intersection

The conjunction AND tells 4D to do an intersection of the two sets. The word intersection means exactly what you think it means: find the place where the two sets intersect; that is, find the records that the two sets have in common.

 

Query Tutorial: AND = INTERSECTION

OR = Union

The conjunction OR tells STATIC to do a Union of the sets. The word Union means exactly what you think it means: Join the sets together. If a record is in either set, it will be in the result set.

If a record is a member of either set, then it is counted as a part of the result. However, if a record is a member of more than one of the united sets, the record is still only counted once.

 

Query Tutorial: OR = UNION

EXCEPT = Difference (almost)

The conjunction EXCEPT tells STATIC to do a Difference of the two sets, but only put into the result set the records in set A that are not in set B. So that you will understand EXCEPT, here is a graphic example:

 

Query Tutorial: EXCEPT = DIFFERENCE



Harrowex Pty Ltd
http://www.hxmedical.com
Voice:+ 61 4 27 344 279
Fax: +61 3 52 439 019
static@hxmedical.com