Filtering on More than One Condition2:51 with Andrew Chalkley
You're not restricted to just using one condition, you can test rows of information against multiple conditions. You can choose whether you retrieve rows that match both of your conditions or either of them.
You can compare multiple values in a
WHERE condition. If you want to test that both conditions are true use the
AND keyword, or either conditions are true use the
SELECT <columns> FROM <table> WHERE <condition 1> AND <condition 2> ...; SELECT <columns> FROM <table> WHERE <condition 1> OR <condition 2> ...;
SELECT username FROM users WHERE last_name = "Chalkley" AND first_name = "Andrew"; SELECT * FROM products WHERE category = "Games Consoles" AND price < 400; SELECT * FROM movies WHERE title = "The Matrix" OR title = "The Matrix Reloaded" OR title = "The Matrix Revolutions"; SELECT country FROM countries WHERE population < 1000000 OR population > 100000000;
See all of the SQL used in SQL Basics in the SQL Basics Cheat Sheet.
You need to sign up for Treehouse in order to download course files.Sign up