Page 171 - Informatics_Practices_Fliipbook_Class12
P. 171
For example, to display ID, first name, last name, and the Salary of all employees whose first name starts with 'R'.
SELECT ID, FName, LName, Salary
FROM EMPLOYEE
WHERE FName LIKE 'R%';
Execution of the above query will produce the output shown in Table 4.24.
ID FName LName Salary
10001 Raj Reddy 100000
10006 Rajit Gadh 60000
Table 4.24 Employees whose first name begins with 'R%'
Note that there are two tuples having the first name that matches the pattern 'R%'(FName starting with R).
Query: Display ID, first name, last name, and the Salary of employees whose first name starts with 'R' and salary in
the sixty thousand range, i.e., a five-digit number beginning 6.
Solution:
SELECT ID, FName, LName, Salary
FROM EMPLOYEE
WHERE FName LIKE 'R%' AND Salary LIKE '6____';
Execution of the above query will produce the output shown in Table 4.25.
ID FName LName Salary
10006 Rajit Gadh 60000
Table 4.25 Employees whose first name begins with 'R%' and have a salary in the range of sixty thousand
Query: Display the employee ID and first name of all employees whose first name contains two a's or two e's.
SELECT ID, FName
FROM EMPLOYEE
WHERE FName LIKE '%a%a%' OR FName LIKE '%e%e%';
Execution of the above query will produce the output shown in Table 4.26.
ID FName
10001 Taran
10008 Naval
10009 Naveen
10010 Savita
Table 4.26 Employees whose first name contains two a's or two e's
Query: Display the first name, last name, and date of birth of all employees who were born in 1980.
Solution:
SELECT FName, LName, DOB
FROM EMPLOYEE
WHERE DOB LIKE '1980______';
Database Query using SQL 157

