SELECT order.date,
vehicle.year,
vehicle.make,
vehicle.model,
SUM(part.price * order_details.quantity) AS price,
order.paid
FROM vehicle
INNER JOIN user
ON user.id = vehicle.user_id
INNER JOIN order
ON order.user_id = user.id
INNER JOIN order_details
ON order_details.order_id = order.id
INNER JOIN part
ON part.id = order_details.part_id
答案 0 :(得分:0)
ORDER是大多数SQL实现中的保留关键字;你可能需要使用反引号来划分表名。
SELECT `order`.date,
vehicle.year,
vehicle.make,
vehicle.model,
SUM(part.price * order_details.quantity) AS price,
`order`.paid
FROM vehicle
INNER JOIN user
ON user.id = vehicle.user_id
INNER JOIN `order`
ON `order`.user_id = user.id
INNER JOIN order_details
ON order_details.order_id = `order`.id
INNER JOIN part
ON part.id = order_details.part_id