From the course: SQL Essential Training

Types of SQL operators - SQL Tutorial

From the course: SQL Essential Training

Start my 1-month free trial

Types of SQL operators

- All right. So now, we are pretty dangerous with our ability to display and order fields but we can become even more stealth by giving ourselves precise tools that allow us to ask specific questions. Here's what I mean by that. With what we've learned so far, to answer a question like how many customers' last names begin with B? You could write a SQL query to select records from the customer table, sort the data alphabetically by last name, then, just manually count the names ending in B. Manually counting your results may be fine for a few records, but what if our database was much larger and contained millions of customers? Would you really want to manually count all the B names then? I don't think so. Fortunately, SQL has some tools that not only allow us to narrow down the results of our query to very specific data, but also to order and filter our data by conditions you specify. Let's see what these new statements can do. Okay, we've done quite a lot. What we're about to do next is enhance our ability to write queries by introducing a new clause called the where clause. Before getting into the where clause, it's important that we pause and take note of some of the common operators that will be used in conjunction with the where clause. So, there are three main operator types which fall under arithmetic, comparison, and logical operators. Under arithmetic operators, there is add, subtract, multiply, divide, and modulo. Some common comparison operators are equal to, not equal to, greater than, less than, greater than or equal to, and less than or equal to. And there are also logical operators which are and, or, in, like, and between. Up next, let's take a look at how these common operators will be used in conjunction with the where clause and thereby give ourselves the ability to greatly refine and respond to inquiries about our data.

Contents