Page 164 - Informatics_Practices_Fliipbook_Class12
P. 164
AND, OR, and NOT. For example, the following SQL statement retrieves the names of all male employees as shown
in Table 4.8:
SELECT FName, LName
FROM EMPLOYEE
WHERE Gender = 'M';
Executing the above statement will produce output shown in Table ________.
FName Lname
Raj Reddy
Dhiraj Bora
Hiten Oberoi
Anshul Verma
Rajit Gadh
Taran Adarsh
Naval Dhingra
Table 4.8: Names of male employees
Similarly we can use any of the relational and logical operators to specify conditions in the where clause. Consider the
following examples:
Query: To display first name and the city of employees whose salary is greater than 70000 and who do not live in Delhi.
SELECT FName,City FROM EMPLOYEE
WHERE City != 'Delhi' AND Salary > 70000;
Executing the above statement will produce output shown in Table 4.9.
FName City
Raj Andhra Pradesh
Dhiraj Guwahati
Hiten Jamshedpur
Ansul Noida
Table 4.9: First name and the city of employees whose salary is greater than 70000 and who do not live in Delhi
Query: To display the records of employees who either live in Delhi or in Noida.
SELECT *
FROM EMPLOYEE
WHERE City = 'Delhi' OR City != 'Noida'
On executing the above statement, SQL will produce output shown in Table 4.10.
ID FName LName Gender Address City Pin_Code DOB Salary Dept_No
10003 Muskan Taneja F 8/33, Geeta Delhi 110031 1990-01-25 100000 2
Colony
10005 Anshul Verma M House 10, Sector Noida 201304 1990-01-01 100000 1
16, Gautum Budh
10008 Naval Dhingra M E-14 Vivek Vihar Delhi 110095 1975-08-04 70000 2
Table 4.10: Details of employees who either live in Delhi or in Noida
150 Touchpad Informatics Practices-XII

