56.6k views
2 votes
Write a query to add the EmpName from the Emp table of the employee who accepted the order. the result table that should be generated from your SELECT command and will have 5 columns: (orderID, OrderDate, CustID, CustomerName, & EmpName

User Oluyemi
by
7.8k points

1 Answer

3 votes

Final answer:

To add the EmpName from the Emp table of the employee who accepted the order, you can use the SELECT statement with a JOIN clause.

Step-by-step explanation:

To add the EmpName from the Emp table of the employee who accepted the order, you can use the SELECT statement with a JOIN clause. Here's an example query SELECT Orders.orderID, Orders.OrderDate, Orders.CustID, Customers.CustomerName, Emp.EmpName FROM Orders JOIN Customers ON Orders.CustID = Customers.CustID JOIN Emp ON Orders.EmpID = Emp.EmpID WHERE Orders.Accepted = true;This query joins the Orders table with the Customers table on the CustID column and the Emp table on the EmpID column. It selects the desired columns and only includes orders that have been accepted. The result table will have 5 columns: orderID, OrderDate, CustID, CustomerName, and EmpName.

User Iknow
by
8.6k points