PQL And & Or

The PQL AND & OR Operators
The AND operator displays a record if both the first condition and the second condition are true. The OR operator displays a record if either the first condition or the second condition is true.

AND Operator Example
Now we want to select only the ponies with the first name equal to "Pinkie" AND the last name equal to "Pie":

We use the following SELECT statement:

The result-set will look like this:

OR Operator Example
Now we want to select only the ponies with the first name equal to "Pinkie" OR the first name equal to "Photo":

We use the following SELECT statement:

The result-set will look like this:

Combining AND & OR
You can also combine AND and OR (use parenthesis to form complex expressions). Now we want to select only the ponies with the last name equal to "Pie" AND the first name equal to "Pinkie" OR to "Photo":

We use the following SELECT statement:

The clause LastName='Pie' will match both Inkie and Pinkie Pie, FirstName='Pinkie' will disregard Inkie and only match Pinkie, FirstName='Photo' will not match Photo Finish since clauses outside the parenthesis will take precedence over clauses inside the parenthesis and she is not matched in the first clause.

The result-set will look like this: