Exp 4
Exp 4
**ANY Operator**
FROM employees
WHERE salary > ANY (SELECT salary FROM employees WHERE department = 'HR');
This query returns employees whose salary is greater than any salary in the HR department.
2. **ALL Operator**
FROM employees
WHERE salary > ALL (SELECT salary FROM employees WHERE department = 'HR');
```
This query returns employees whose salary is higher than every salary in the HR department.
3. **IN Operator**
The `IN` operator checks if a value is present in a list of values or a subquery result.
FROM employees
This query fetches employees who work in either HR, Sales, or Marketing departments.
4. **EXISTS Operator**
The `EXISTS` operator checks for the existence of rows returned by a subquery.
SELECT name
FROM employees e
This query lists employees who are managers (based on whether their `employee_id` appears as
`manager_id` in the `departments` table).
SELECT name
FROM employees e
This query returns employees who are not managing any projects.
6. **UNION Operator**
The `UNION` operator combines the result sets of two or more `SELECT` queries. Duplicate values are
removed.
UNION
This query lists employees from either the HR or Finance departments without duplicates.
7. **INTERSECT Operator**
The `INTERSECT` operator returns rows that are common to both result sets.
SELECT name FROM employees
INTERSECT
This query returns employees from HR whose salary is greater than 50,000.
8. **CONSTRAINTS**
Constraints are rules enforced on data columns, such as `PRIMARY KEY`, `FOREIGN KEY`, `UNIQUE`,
`CHECK`, and `NOT NULL`.
department_name VARCHAR(50)
);
name VARCHAR(50),
department_id INT,
);