如何从不同 tables SQL 的日期范围输出 table 字段的结果
how to output results of table field from a date range on different tables SQL
我有 table 个带有 table 个标题
员工
staffID staffName staffAge
产品
productID productDescription productCost
订单
orderID customerID orderDate orderLocation
orderServedby
orderID staffID servedBy
订单汇总
orderID customerID productID summaryOfOrder
我想根据日期(orderDate
)
到目前为止我有这个...
SELECT
staff.staffID,
order.orderLocation, orderSummary.productID
FROM
staff
INNER JOIN
orderServedby ON staff.staffID = orderServedby.staffID
INNER JOIN
ordersummary ON product.ProductID = orderSummary.productID
WHERE
OrderDate BETWEEN #07/04/1996# AND #07/09/1996#;
我不确定如何将它们 link 在一起,因为它们都依赖 orderID
来获得正确的列?抱歉,我是 SQL 的新手。谢谢
这应该让你开始:
SELECT
staff.staffID,
order.orderLocation,
orderSummary.productID
from Order
inner join orderServedBy on orderServedBy.OrderId = Order.OrderId
inner join orderSummary on orderSummary.OrderId = Order.OrderId
where OrderDate BETWEEN #07/04/1996# AND #07/09/1996#
and ServedBy = '<some value here>'
我有 table 个带有 table 个标题
员工
staffID staffName staffAge
产品
productID productDescription productCost
订单
orderID customerID orderDate orderLocation
orderServedby
orderID staffID servedBy
订单汇总
orderID customerID productID summaryOfOrder
我想根据日期(orderDate
)
到目前为止我有这个...
SELECT
staff.staffID,
order.orderLocation, orderSummary.productID
FROM
staff
INNER JOIN
orderServedby ON staff.staffID = orderServedby.staffID
INNER JOIN
ordersummary ON product.ProductID = orderSummary.productID
WHERE
OrderDate BETWEEN #07/04/1996# AND #07/09/1996#;
我不确定如何将它们 link 在一起,因为它们都依赖 orderID
来获得正确的列?抱歉,我是 SQL 的新手。谢谢
这应该让你开始:
SELECT
staff.staffID,
order.orderLocation,
orderSummary.productID
from Order
inner join orderServedBy on orderServedBy.OrderId = Order.OrderId
inner join orderSummary on orderSummary.OrderId = Order.OrderId
where OrderDate BETWEEN #07/04/1996# AND #07/09/1996#
and ServedBy = '<some value here>'