Link Search Menu Expand Document

Module 2: Filter PDF Data Using WHERE clause - Part 3

Previous Tutorial - Next Tutorial

The WHERE clause becomes really interesting when we consider combining more than one field to filter a result. The WHERE clause can be combined with AND/OR and NOT logical operators to create more complex conditions. The AND/OR operators are used to filter records based on more than one condition. So basically they call the boolean logical operators.

The AND operator displays a record if and only if all the specified conditions are evaluated to true. So this table shows all possible combinations of the condition. Let's see this AND operator practically. Again back to the SQL server management studio. Now from this person table, I want to find that person whose first name is Kevin and last name is Brown by using the AND operator. So let's see how we can use this And Boolean logical operator in the WHERE clause(WHERE FirstName = 'Kevin' AND LastName = 'brown'). If I execute this query, I will get that person whose first name is Kevin and the last name is Brown.

Filtering PDF Data

So the same way you can use the OR operator. In OR operator, it displays only those records if and only if the specified condition evaluates to true. So here in the table, you can see that in any case, if one of the conditions is evaluated to true, then the end result will also evaluate to true. That means you will get the data from the table if any of the conditions evaluate to true. In this query, if I write OR operator over here like (WHERE FirstName = 'Kevin' OR LastName = 'brown') and if I execute this query, it gives me that person whose first name is either Kevin or last name is either Brown.

So the NOT operator displayed a record if the condition is not true. So for example, in this person's table, I want to list out that person whose title is not Mr. and not Mrs. So let's see how we can write the WHERE clause using the NOT operator(WHERE NOT Title = 'Mr.' AND NOT Title = 'Ms.').

If I execute this query, I will get that person whose title is not Mr and whose title is not Ms. So in the next slide, we will learn about the ORDER by clause, which will help us to identify which column to use to sort the resulting data.

Web API for developers Free Trial Offline SDK

Here's SQL video tutorial:

Other useful tutorials:


Back to top

© , Learn SQL 24 / 7 — All Rights Reserved - Terms of Use - Privacy Policy