The WHERE clause is placed after the FROM clause in a SELECT query. Using the example of players with more than 40 appearances in games, you can execute the following query:
USE lahmansbaseballdb;
SELECT playerid, g_all, g_batting, g_defense FROM appearances
WHERE g_all > 40;
The criterion we are setting in the WHERE clause (for example, g_all > 40) is called an expression. There are different expression operators you can use.
The following are the comparison operators:
Symbol | Description | Examples |
= | Equal to | column = 'text' column = 1 |
>= | Greater than or equal to | column >= 1 |
> | Greater than | column > 1 |
<= | Less than or equal to | column <= 1 |
< | Less than | column < 1 |
<> | Does not equal | column <> 'text' column <> 1 |
!= | Does not equal | column != 'text' column != 1 |
Expressions will be covered in more detail in Chapter 9, Working with Expressions.