The SQL WHERE clause is used to specify a condition while fetching the data from single table or joining with multiple tables.
If the given condition is satisfied, then only it returns specific value from the table. You would use WHERE clause to filter the records and fetching only necessary records. The WHERE clause is not only used in SELECT statement, but it is also used in UPDATE, DELETE statement, etc.
Syntax: The basic syntax of SELECT statement with WHERE clause is as follows:
SELECT column1, column2, columnN FROM table_name WHERE [condition]
Example: Consider the DEPT table having the following records:
Following is an example, which would fetch deptno, dname and location fields from the DEPT table where deptno is greater than 20:
SELECT deptno, dname, location FROM DEPT WHERE deptno > 20;
This would produce the following result: