Dips > Data Processing > Query Data
This example demonstrates a more complex query which uses both AND and OR operators, and brackets.
TYPE == joint && (TRAVERSE == 1 || TRAVERSE == 2)
Select Query
Data
from the toolbar or the Analysis menu.
Create the Expression TYPE == joint.
Select the Expression button.
Select the AND button.
Select the left bracket " ( " button.
Create the Expression TRAVERSE == 1
Select the Expression button.
Select the OR button.
Create the Expression TRAVERSE == 2
Select the Expression button.
Select the right bracket " ) " button.
Select OK.
For the example.dip file, this query should create a new file with 21 rows. Note:
All entries in the TYPE column are "joint"
All entries in the TRAVERSE column are either 1 OR 2
When creating more complex queries such as this, the user should be extra careful with the use of the AND and OR operators, and brackets, to make sure that the query they create will perform the intended search. It is possible to create a valid query which does not carry out the desired search. For example, if the brackets are removed in this example, the query will behave quite differently:
TYPE == joint && TRAVERSE == 1 || TRAVERSE == 2
This query will find all rows with TYPE = joint AND Traverse = 1, and ANY row with Traverse = 2. Similarly, the query:
TRAVERSE == 1 || TRAVERSE == 2 && TYPE == joint
will find all rows with TYPE = joint AND Traverse = 2, and ANY row with Traverse = 1 (since the AND operator takes precedence over the OR operator). However, the query:
(TRAVERSE == 1 || TRAVERSE == 2) && TYPE == joint
will give identical results to the original query, since we are simply reversing expressions on either side of the AND operator.