From the course: Learning SQL Programming

Unlock the full course today

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

Narrow down a query with WHERE

Narrow down a query with WHERE - SQL Tutorial

From the course: Learning SQL Programming

Start my 1-month free trial

Narrow down a query with WHERE

- [Instructor] When we're asking the database for information, it's very helpful to be able to give some parameters. We can use the WHERE keyword to add a condition to a SELECT statement. For example, if I wanted to see all of the records only for people who live in California, I could use my SELECT * statement and then add a WHERE clause with a predicate or condition, state_code=CA. In this predicate, CA is an expression. In this case, the text we use here in the expression is case-sensitive which means that if the capitalization differs from what's in the database, it won't match. We might look at lower-case ca and upper-case CA and think of them as the same thing, but to the database, they're completely different. Whether a field is treated as case-sensitive or not is something that can be defined when constructing the table as part of the database schema. I'll change capital CA here, to lower-case ca and run my query again. No results. But upper-case CA works because it matches…

Contents