Execute one join command to display all of the data included in the two tables f
ID: 3750921 • Letter: E
Question
Execute one join command to display all of the data included in the two tables for each set of tables
CREATE TABLE Employees (
LastName varchar(30) NOT NULL,
FirstName varchar(30) NOT NULL,
EmployeesID VARCHAR(20) NOT NULL,
Certifications varchar(20),
Payrate varchar(20),
PRIMARY KEY (EmployeesID) );
CREATE TABLE Certifications (
HighRise varchar(30) NOT NULL,
ToxicWaste varchar (30) NOT NULL,
Level2DL varchar(30) NOT NULL,
CertificationID int NOT NULL,
Paramedic varchar(20),
EmployeesID INT,
LastName varchar(30) NOT NULL,
FirstName varchar(30) NOT NULL,
PRIMARY KEY (CertificationID));
Explanation / Answer
According to your question, we need to find data of an employee from two tables and that only in one join command. So, we should find the common attribute in both the tables on which we should apply the join.
Here, the common command is EmployeeID which is unique for every employee. Also, some attributes like first name and last name become redundant(repeat) after applying the join so we need to have only one such attribute after join, not from both tables. Following is the command, based on mysql:
SELECT Employees.LastName , Employees.FirstName , Employees.EmployeesID, Certifications, Payrate, HighRise, ToxicWaste, Level2DL, CertificationID, Paramedic FROM Employees INNER JOIN Certifications ON Employees.EmployeeID=Certifications.EmployeeID;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.