To extract information from a database that fulfill a specific criteria, use the SQL WHERE clause.
The SQL WHERE clause can be used with SELECT, UPDATE, and DELETE SQL statements.
Syntax:
1 |
<SELECT, UPDATE, OR DELETE statement> WHERE <column name> <operator> <value>
|
In the SELECT, UPDATE, OR DELETE statement field, enter a SELECT, UPDATE, or DELETE statement.
In the column name field, enter a valid column name.
In the operator field, use one of the following operators:
| Operator | Description |
| = | Equal |
| != | Not Equal. (**Does not work in all versions of SQL. <> may be needed instead**) |
| < | Less than |
| > | Greater than |
| <= | Less than or equal |
| >= | Greater than or equal |
| BETWEEN | Between an inclusive range |
| LIKE | Pattern Search |
| IN | If you know the exact value you want to return for at least one of the columns. |
In the value field, enter a valid value corresponding to your operator. Text or String values should be wrapped with single quotes. Integer or numeric values should NOT be enclosed in quotes.
Example:
Suppose there is a database with a table named birthdays, which includes the following dataset:
| FirstName | LastName | BirthDate |
| Brian | Johnson | 1/8/1975 |
| Nick | Thomson | 3/19/1965 |
| Tyler | Jones | 12/17/1994 |
To select the row(s) with birthday(s) only for people with the first name of Nick, use the following query:
1 |
SELECT * FROM birthdays WHERE FirstName = 'Nick'
|




