# Select Information from All Tables [closed]

EER Diagram

Question

List the customer number, customer name (first and last), order number, order date, employee number, employee name (first and last), product number, product name, and order cost (product quantity * product unit price) for telephone orders (A telephone order has an associated employee) placed on January 23, 2007 and the order cost exceeds \$150. Order the result by the order cost in descending order.

My Code

``````SELECT
Customer.CustNo,
Customer.FirstName,
Customer.LastName,
`Order`.OrderNo,
`Order`.OrderDate,
Employee.EmpNo,
Employee.FirstName,
Employee.LastName,
Product.ProdNo,
Product.ProdName,
CONCAT('\$', ProductInOrder.Qty * SUBSTRING(Product.Price, 2)) AS `Order Cost`
From Customer, `Order`, Employee, Product, ProductInOrder
WHERE
`Order`.Employee_EmpNo IS NOT NULL                          AND
STR_TO_DATE(`Order`.OrderDate, '%m/%d/%Y') = '2007-1-23'    AND
ProductInOrder.Qty * SUBSTRING(Product.Price, 2) > 150
ORDER BY `Order Cost` DESC;
``````

Result

14:57:29 SELECT Customer.CustNo, Customer.FirstName, Customer.LastName, `Order`.OrderNo, `Order`.OrderDate, Employee.EmpNo, Employee.FirstName, Employee.LastName, Product.ProdNo, Product.ProdName, CONCAT('\$', ProductInOrder.Qty * SUBSTRING(Product.Price, 2)) AS `Order Cost` From Customer, `Order`, Employee, Product, ProductInOrder WHERE `Order`.Employee_EmpNo IS NOT NULL AND STR_TO_DATE(`Order`.OrderDate, '%m/%d/%Y') = '2007-1-23' AND ProductInOrder.Qty * SUBSTRING(Product.Price, 2) > 150 ORDER BY `Order Cost` DESC LIMIT 0, 1000 1000 row(s) returned 0.290 sec / 0.011 sec

My Question

I think there is something wrong with the code `From Customer, Order, Employee, Product, ProductInOrder`. How to join all the tables together? If I use `INNER JOIN`, it will be more complicated.

## closed as off-topic by ypercubeᵀᴹ, Max Vernon, RolandoMySQLDBA, RLF, Shawn MeltonOct 9 '14 at 17:52

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – ypercubeᵀᴹ, Max Vernon, RolandoMySQLDBA, RLF, Shawn Melton
If this question can be reworded to fit the rules in the help center, please edit the question.

It says like syntax error, which you missed the `,`

``````SELECT
Customer.CustNo,
Customer.FirstName,
Customer.LastName,
`Order`.OrderNo,
`Order`.OrderDate,
Employee.EmpNo,
Employee.FirstName,
Employee.LastName,
Product.ProdNo,
Product.ProdName,
CONCAT('\$', ProductInOrder.Qty * SUBSTRING(Product.Price, 2)) AS `Order Cost`
From Customer, `Order`, Employee, Product, ProductInOrder
WHERE
`Order`.Employee_EmpNo IS NOT NULL                          AND
STR_TO_DATE(`Order`.OrderDate, '%m/%d/%Y') = '2007-1-23'    AND
`Order`.Cost > 150
ORDER BY `Order`.Cost DESC;
``````
• Codes updated but I problem is still here. =[ – Kin Oct 9 '14 at 6:48
• Still its a syntax error only, updated – senK Oct 9 '14 at 6:50