Other related articles:

Recently viewed articles:

SQL Where Clause

RDBMS packages store data which is extracted using SQL commands. The data extracted by SQL provides some kind of information. Sometimes you have to select data based on some conditions. To implement such conditions we need to use WHERE clause.

For example, you could write query to find all employees working in department no. 10. We can  use the WHERE clause in SELECT statements to filter data so that we get only the data we want.

One or more conditions can be set by using WHERE clause which must be satisfied by each record to become part of the result. For example if you are asked for a list of employees who work in Deptno 10, you have to specify that the column deptno  must be equal to 10. SQL statement for this request appears as below:

SELECT ename AS EmployeeName

FROM emp

WHERE deptno = 10;

This query will provide the following results:

Image 7

We can use different logical operators in WHERE clause according to the results we need (Note: There is a separate topic on SQL Logical Operators and their precedence). The value passed on right hand size should be mentioned in quotes, if it is a character or date value. For example, if we need to find the deptno for Scott, the query would be like:

SELECT deptno FROM emp WHERE ename = ‘SCOTT’;

 

Image 8