尝试加入表列时,第一个on出现错误1054


SELECT od.order_header_id, product_name, order_qty, customer_name, oh.order_date, oh.total_price
FROM order_detail AS od
INNER JOIN order_header AS oh
ON (oh.total_price = od.total_price)

INNER JOIN order_header AS oh1
ON (oh1.order_date = od.order_date )

INNER JOIN product AS p 
ON (p.product_name = od.product_name)

INNER JOIN customer AS c
ON (c.customer_name = od.customer_name )    
WHERE oh1.order_date BETWEEN '2022-01-01' AND '2022-01-07'
GROUP BY od.order_header_id
ORDER BY od.order_header_id;

当我尝试运行这个查询时,它说第一次打开时有错误。我收到错误1054,说order_detail表没有名为"total_price"的列。

MySQL中出现错误1054是因为MySQL找不到您在语句中指定的列或字段

*此查询用于收集这些不同的列,并显示按order_header_id 排序的2022-01-01至2022-01-07的数据

SELECT order_detail.order_header_id, product.product_name, order_qty, customer.customer_name, order_header.order_date, order_header.total_price
FROM order_detail
INNER JOIN order_header
ON (order_header.order_header_id = order_detail.order_header_id)

INNER JOIN product
ON (product.product_id = order_detail.product_id)

INNER JOIN customer
ON (customer.customer_id = order_header.customer_id)
WHERE order_date BETWEEN '2022-01-01' AND '2022-01-07'
ORDER BY order_header_id;

我用错了!lol

相关内容

  • 没有找到相关文章

最新更新