The WHERE keyword is used when it is necessary to filter out specific data. It adds conditions which records must meet in order to be included in the query. The following query displays all of the records in the students table.
id | last_name | first_name | grade |
001 | Holmes | Guy | 88 |
002 | Atwell | James | 73 |
003 | O'Hara | Alice | 96 |
004 | Peterson | Holly | 83 |
If, however, we only want to see the records of those students with a grade greater than 85, the WHERE keyword is required.
id | last_name | first_name | grade |
001 | Holmes | Guy | 88 |
003 | O'Hara | Alice | 96 |
The students with grades of 85 and less are now excluded from the query results.
The keywords AND and OR can be used after WHERE to make the query even more specified. Their usage can be seen in the following interactive query. Click on the grayed out sections to add or remove them from the query.
name | capital | language | population |
Spain | Madrid | Spanish | 47350000 |
Iceland | Reykjavík | Icelandic | 366425 |
Peru | Lima | Spanish | 32000000 |
Vietnam | Hanoi | Vietnamese | 97340000 |
The content on this site is the property of Milo Roberts (MiloRoberts.com) and may not be reproduced.