this query is not wrong and not giving any error i'm ruining this query on w3school http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all
open this link and paste the query.
SELECT c.CustomerName, p.ProductName
FROM Customers c inner join Orders o on c.CustomerID = o.CustomerID
JOIN OrderDetails od on od.OrderID = o.OrderID
JOIN Products p on p.ProductID = od.ProductID;
Answer from Ayaz ahmed khan on Stack Overflowthis query is not wrong and not giving any error i'm ruining this query on w3school http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all
open this link and paste the query.
SELECT c.CustomerName, p.ProductName
FROM Customers c inner join Orders o on c.CustomerID = o.CustomerID
JOIN OrderDetails od on od.OrderID = o.OrderID
JOIN Products p on p.ProductID = od.ProductID;
Refer to their documentation here - https://www.w3schools.com/sql/sql_join_inner.asp
Section - "JOIN Three Tables"
If I re-write your code like below then it works fine in W3School's try it editor.
SELECT c.CustomerName, p.ProductName
FROM ( ( ( Customers c inner join Orders o on c.CustomerID = o.CustomerID )
inner JOIN OrderDetails od on od.OrderID = o.OrderID )
inner JOIN Products p on p.ProductID = od.ProductID );
For any SQL to actually be translated and do any sort of creation, manipulation, or delegation a database system is needed. The w3schools website always has these online SQL editors as examples, what database system are they using?
The w3schools website has an online SQL editor with an examplary database. I would love to find out the entity relationships. Does anyone know how the get the ER diagram or know the initial source?
Thx in advance :)
The update with join syntax is specific for each db
The query you are using is valid for SQLSERVER
UPDATE OrderDetails
SET OrderDetails.ProductID = Orders.CustomerID
FROM Orders
INNER JOIN OrderDetails
ON OrderDetails.OrderID = Orders.OrderID
but not for my MySQL
UPDATE OrderDetails
INNER JOIN OrderDetails
ON OrderDetails.OrderID = Orders.OrderID
SET OrderDetails.ProductID = Orders.CustomerID
This works:
UPDATE OrderDetails
SET ProductID = (SELECT CustomerID FROM Orders WHERE OrderDetails.OrderID = Orders.OrderID)
WHERE OrderID IN (SELECT OrderID FROM Orders);
Is this what you want?