Often, you need to ask for data that meets more than one criterion. Explore logic in a SELECT statement.
- [Instructor] When we're asking for a set of rows…from a database, we can pretty easily…find values that match a term exactly.…All of the people who signed up to get shirts,…or all of the people in California.…But we can add a little bit of logic to our statements too,…in order to start asking more interesting questions…about the data.…For example, we can ask for the names…of everyone who is in California and who asked for a shirt.…For that I'll write select, first name, last name.…
From our people table, where state equals California,…and, shirt or hat equals shirt.…This and term here is a logical operator,…and SQL supports some of them as part of a predicate.…You can chain them together if you want to ask for records…that have more conditions fulfilled.…I'll run this, and I can see the result.…
I'll add the team field here into my select clause.…And then in the where clause,…I'll add, and team equals blue.…I can search for people in California…who wanted a shirt who signed up for the blue team.…We could also take this last condition here…
- What is SQL?
- Asking for data with SELECT
- Limiting database responses
- Organizing responses
- Asking for data from two or more tables
- Understanding join types and data types
- Transforming data
- Performing math
- Adding and modifying data in a table