Query description
Let's suppose we need to build a query where condition #1 OR condition #2 apply.
For example, we need to find all orders with products from category Beverages or Seafood.
SQL
Here's how such a query would look like in SQL:
SELECT Ord.OrderDate AS "Order Date", Ord.Freight AS "Order Freight"
FROM ((Orders AS Ord
INNER JOIN `Order Details` AS OrdDet ON (OrdDet.OrderID = Ord.OrderID ))
INNER JOIN Products AS Prod ON (OrdDet.ProductID = Prod.ProductID ))
WHERE
(
Prod.CategoryID = 1 OR
Prod.CategoryID = 8 )
As you can see this relatively simple query requires a lot of SQL "coding". We have 3 different tables here, and 2 joins between those tables.
EasyQuery
With EasyQuery this task will be much easier (sorry for the tautology).
You need to perform three simple steps:
- In columns panel you add "Order Date" and "Order Freight" columns.
- Then you change all element to any the root condition group in query panel. It must look like "...where any of the followings apply".
- Finally you add two conditions into columns panel:
- Product Category is equal to Beverages
- Product Category is equal to Seafood
Query 2
Now imagine we need to add another condition which will be mandatory: we need to list only paid orders. So the final query will have the following structure:
Order is paid AND
(Product Category is Beverages OR Seafood)
SQL 2
The SQL statement for this new query will be the following:
SELECT Ord.OrderDate AS "Order Date", Ord.Freight AS "Order Freight"
FROM ((Orders AS Ord
INNER JOIN `Order Details` AS OrdDet ON (OrdDet.OrderID = Ord.OrderID ))
INNER JOIN Products AS Prod ON (OrdDet.ProductID = Prod.ProductID ))
WHERE
(
Ord.Paid = true AND (
Prod.CategoryID = 1 OR
Prod.CategoryID = 8 ) )
EasyQuery 2
With EasyQuery components, it will take one additional step.
- As in the previous case, you add "Order Date" and "Order Freight" columns.
- In query panel add one condition: Order Paid is true.
- Please note that you don't need to change all to any in this case.
- After that press {+} button in the first row to add a new group of conditions after the first condition.
- New condition group will automatically take any linking.
- EasyQuery will automatically add a condition in the new group. Change the attribute in that condition to "Product Category" and select "Beverages" in the right part of the condition.
- Add one more condition into the group. Use (+) button in the group row (but not in root row!) to do it. Select "Product Category" as an attribute and "Seafood" as a value for this condition.
Product Category is equal to Seafood
Finally you should see something like the following: