select d.`订单ID`,d.`产品ID`,c.`产品名称`,d.`单价`,d.`数量` ,(d.`单价`*d.`数量`) AS 金额 from `订单明细` as d
LEFT JOIN `产品` as c on d.`产品ID`=c.`产品ID`
where d.`订单ID`='10248' or `订单ID`='10254'
select d.`订购日期`,d.`运货商`,y.`公司名称`,sum(dm.`数量`) as 总数,d.`货主地区` from `订单` d
LEFT JOIN `订单明细` dm ON d.`订单ID`=dm.`订单ID`
LEFT JOIN `运货商` y ON d.`运货商`=y.`运货商ID`
where d.`订购日期`>='1997-01-01 00:00:00' and d.`订购日期`<='1997-12-31 24:00:00'
GROUP BY y.`公司名称`