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.

Adding more criteria to a statement

Adding more criteria to a statement - SQL Tutorial

From the course: Learning SQL Programming

Start my 1-month free trial

Adding more criteria to a statement

- [Instructor] When we're asking for a set of fields from a database, we can pretty easily find values that match a term exactly. All the people who signed up to get T-shirts or all the people in California. But we can add a little bit of logic to our statements, too, in order to start to ask more interesting questions about the data. For example, we could ask for the names of everyone who is in California and who asked for a shirt. To do that, I would write SELECT first_name comma last_name FROM people WHERE state_code=CA AND shirt_or_hat=shirt. This AND here, is a logical operator and SQL supports these logical operators as part of a predicate. You can chain logical conditions together if you want to ask for records that have more conditions fulfilled. I'll add a team here, as another condition and I'll add it to my SELECT statement as well, so we can see the result. This will search for people in California who wanted a shirt, who signed up for the Angry Ants team. We could also…

Contents