Key Concepts

Review core concepts you need to learn to master this subject

AND Operator

SELECT model FROM cars WHERE color = 'blue' AND year > 2014;

The AND operator allows multiple conditions to be combined. Records must match both conditions that are joined by AND to be included in the result set. The given query will match any car that is blue and made after 2014.

Queries
Lesson 1 of 1
  1. 1
    In this lesson, we will be learning different SQL commands to query a single table in a database. One of the core purposes of the SQL language is to retrieve information stored in a database. …
  2. 2
    Previously, we learned that SELECT is used every time you want to query data from a database and * means all colu…
  3. 3
    Knowing how SELECT works, suppose we have the code below: SELECT name AS ‘Titles’ FROM movies; Can you guess wha…
  4. 4
    When we are examining data in a table, it can be helpful to know what distinct values exist in a particular column. [DISTINCT](https://www.codecademy.com/resources/docs/sql/commands/select-disti…
  5. 5
    We can restrict our query results using the WHERE clause in order to obtain only the information we want. Following…
  6. 6
    LIKE can be a useful operator when you want to compare similar values. The movies table contains two films with si…
  7. 7
    The percentage sign % is another wildcard character that can be used with LIKE. This statement below filters the re…
  8. 8
    By this point of the lesson, you might have noticed that there are a few missing values in the movies table. More often than not, the data you encounter will have missing values. Unknown values a…
  9. 9
    The BETWEEN operator is used in a [WHERE](https://www.codecademy.com/resources/docs/sql/commands/where?page_ref=c…
  10. 10
    Sometimes we want to combine multiple conditions in a WHERE clause to make the result set more specific and useful…
  11. 11
    Similar to AND, the OR operator can also be used to combine multiple conditions in WHERE, but there is a fundamental…
  12. 12
    That’s it with WHERE and its operators. Moving on! It is often useful to list the data in our result set in a parti…
  13. 13
    We’ve been working with a fairly small table (fewer than 250 rows), but most SQL tables contain hundreds of thousands of records. In those situations, it becomes important to cap the number of rows…
  14. 14
    A CASE statement allows us to create different outputs (usually in the SELECT statement). It is SQL’s way of handling…
  15. 15
    Congratulations! We just learned how to query data from a database using SQL. We also learned how to filter queries to make the information more specific and useful. Let’s summarize: - [SELECT]…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo