L5 More SQL
L5 More SQL
NULL = 1
NULL <> 1
NULL > 1
NULL = NULL
Nothing equals null. Not even null equals null because each null
could be different.
the second nested query selects the project numbers of projects that have an employee
with last name ‘Smith’ involved as worker.
This query will select the Essns of all employees who work the same
(project, hours) combination on some project that employee ‘John Smith’
(whose Ssn = ‘123456789’) works on
One way to write this query is shown in Q7, where we specify two nested correlated
queries; the first selects all DEPENDENT tuples related to an EMPLOYEE, and the
second selects all DEPARTMENT tuples managed by the EMPLOYEE. If at least one of
the first and at least one of the second exists, we select the EMPLOYEE tuple
If no matching tuple
If no matching tuple
INCORRECT QUERY:
SELECT Dno, COUNT (*)
FROM EMPLOYEE
WHERE Salary>40000
GROUP BYDno
HAVING COUNT (*) > 5;
updates is intended
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 7- 51
View Update
R5:
CREATE TRIGGER SALARY_VIOLATION
BEFORE INSERT OR UPDATE OF Salary, Supervisor_ssn ON
EMPLOYEE