Answer: UNION Set Operator
Find a detailed explanation of using UNION in SQL.
We'll cover the following...
We'll cover the following...
Solution
The solution is given below:
Code explanation
The explanation of the solution code is given below:
Line 2: The
SELECTquery selectsEmpNameandProjectNamefromEmployeesandProjects, respectively.Line 3: The data is retrieved from the
Employeestable. We useASto set an alias for the tables.Line 4: A
JOINoperation is applied withProjectsto combine the data based on theEmpIDcolumn.Line 5: The
UNIONkeyword is used to combine the results of two queries.Line 6: This part selects projects that currently have no employee linked to them and it renames ‘No Employee Assigned’ in
EmpName.Line 7: The data is retrieved from the
Projectstable.Line 8: The
WHEREclause ...