From the course: Programming Foundations: Databases

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Narrowing query results

Narrowing query results

From the course: Programming Foundations: Databases

Start my 1-month free trial

Narrowing query results

- [Instructor] Using SELECT we can ask for specific rows in our table. But when we use it without qualification we get those fields for all the records in the table. To further refine our SELECT query we can use the WHERE clause to choose only specific records or records which match our criteria. I'll write a query here to get my customer's FirstName, LastName, and state from the customer's table. I'll run it and I'll see that we have a lot of results. Here after the FROM clause, I'll add a WHERE clause to filter these results. We'll take a look at customers only from the state of California. I'll run the query and here they are. I can use some logical operators in my query as well if I want to get results that match more than one condition. Let's take a look at the customers who are from California or Colorado. To do that after WHERE State="CA" I'll add OR State="CO". I'll run this query and then I can see that I have customers returned whose state is California and Colorado. We can…

Contents