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…
- Name the predicate of the following statement: SELECT EyeColor, Age FROM Student WHERE FirstName = 'Tim' ORDER BY LastName ASC;
- Explain what to use to enforce the order in which an expression must be evaluated if the WHERE clause contains multiple expressions to evaluate.
- Identify the best option to join two tables in a database to be able to display data from both.
- List a data type that is not numeric.
- Determine the result of running the following statement on a table containing columns col_1 and col_2:
- INSERT INTO Box (col_1, col_2) VALUES ('A', 'B'), ('A', 'B'), ('A', 'B'), ('A', 'B');
- Determine the best approach of deleting Jon Ramirez (ID 3452) from a Student table.