AND Condition
Last updated 6/04/2022
AND Condition in Five
The AND
condition allows you to test two or more conditions. It requires that all conditions are met for the record to be included in the result set. The Criteria field
is used to filter records. It is used to extract only those records that meet a specified condition. The criteria condition used together with the AND
logical operator, is
only executed if all filter criteria specified are met. The AND
operator displays a record if all the conditions separated by AND
are true.
WHERE Condition_1
AND; Condition_2
AND; Condition_3
...
AND; Condition_4
Create a Query with an AND Condition
Select Menus in the menu.
Click the Add Item button in the list app bar.
Type a title in the Title field.
Click in the Query field to open the Table and Fields Designer.
- Click the Add Table button.
- Select a table.
Click outside of the Table Selector dialog box to close the window.
Select the table and drag to the desired position on the Designer.
Double click the field names required for the query.
In field one, type a condition in the Criteria field.
In field two, type a condition in the Criteria field.
> 1000
= 'Brisbane'
This AND
example will return all patients in the Brisbane suburb that have a patient number greater than 1000. Because the first name and last name fields are included in the query, these
are also included in the result set.
When entering a string it is strongly recommended to use quotes ''
around the value to clearly define that it is a string.
- Click the Save button in the Table and Fields Designer app bar.
- Click the Fields tab.
- Click the Save button in the form app bar.
Ensure to click the Fields tab to have all your query fields saved before committing the form.
Add an AND Condition with Multiple Tables
When creating AND
conditions with multiple tables, Five will automatically create the JOIN
for tables that have relationships defined.
Select Menus in the menu.
Click the Add Item button in the list app bar.
Type a title in the Title field.
Click in the Query field to open the Table and Fields Designer.
- Click the Add Table button.
Select a table.
Select table two.
Select each table and drag to the desired position on the Designer.
In table one, double click the field names required for the query.
In table two, double click the field names required for the query.
In field one, type a condition in the Criteria field.
In field two, type a condition in the Criteria field.
In field three, type a condition in the Criteria field.
= 'Brisbane'
= 'Consultation'
> '2022-04-01'
You will notice Five has prefixed all fields with their table name, for example, Patient.Details. This is required to eliminate any ambiguity as to which field is being referenced, as the same field name may exist in both of the tables.
This AND
example will return all patients in Brisbane that have the appointment details of Consultation and after the date 2022-04-01. Because the first name, last name, and patient number fields are included
in the query, these are also included in the result set.
- Click the Save button in the Table and Fields Designer app bar.
- Click the Fields tab.
- Click the Save button in the form app bar.