WHERE
WHERE is an SQL clause that filters the results from a SELECT, UPDATE, or DELETE statement. It only returns or affects the records that satisfy a specified condition.
Example
Output
Explanation
In the above example, WHERE
clause is used to filter records. It extracts only those employees from the Employees
table whose salary is greater than 50000. All columns of the filtered records are returned and displayed.
Example
Output
Explanation
In the given example, the SELECT * FROM Employees WHERE FirstName = 'John';
SQL statement is selecting all records (*
) from the Employees
table where the FirstName
is 'John'
. This returned a single record where the FirstName
is 'John'
.
Example
Output
Explanation
The SQL command in the example demonstrates the use of the WHERE clause to filter rows in a table. In this case, only employees working in the ‘Sales’ department are returned in the result.
Example
Output
Explanation
The example query selects all columns from the employees
table where the salary
is greater than 5000.
Example
Output
Explanation
The WHERE
clause in the SQL statement is used to extract only the records that fulfill a specified condition. In the example above, only the records where the Country
is ‘Germany’ are extracted from the Customers
table.