Fds - c4 - Basic SQL
Fds - c4 - Basic SQL
Fds - c4 - Basic SQL
Basic SQL
Basic SQL
– In Q8, E and S are two different aliases or tuple variables for the
EMPLOYEE relation
– We can think of E and S as two different copies of EMPLOYEE; E
represents employees in role of supervisees and S represents
employees in role of supervisors
– The join condition joins two different employee records together (a
supervisor S and a subordinate E)
Q1C:SELECT *
FROM EMPLOYEE
WHERE DNO=5 ;
Q1D:SELECT *
FROM EMPLOYEE, DEPARTMENT
WHERE DNAME='Research' AND
DNO=DNUMBER ;
Q11:SELECT SALARY
FROM EMPLOYEE
Q11A: SELECT DISTINCT SALARY
FROM EMPLOYEE
• The LIKE operator allows users to get around the fact that
each value is considered atomic and indivisible
– Hence, in SQL, character string attribute values are not
atomic
• The standard arithmetic operators '+', '-'. '*', and '/' (for
addition, subtraction, multiplication, and division,
respectively) can be applied to numeric attributes and
values in an SQL query
• Example: Query 27: Show the effect of giving all
employees who work on the 'ProductX' project a 10%
raise.
Q27: SELECT FNAME, LNAME, 1.1*SALARY
FROM EMPLOYEE, WORKS_ON, PROJECT
WHERE SSN=ESSN AND PNO=PNUMBER
AND PNAME='ProductX‟ ;