【发布时间】:2019-11-10 23:08:49
【问题描述】:
在 MySQL 中,我查询了连接 3 个表(电影表、库存表和租赁表)得到以下结果:
film_id | title | inventory_id | store_id | rental_ date | return_date
1 | Dinosaur | 1 | 1 | 2018-08-01 | 2018-08-7
1 | Dinosaur | 1 | 1 | 2018-09-01 | 2018-09-12
1 | Dinosaur | 1 | 1 | 2019-10-12 | 2018-10-17
1 | Dinosaur | 2 | 1 | 2019-10-01 | 2018-10-18
1 | Dinosaur | 2 | 1 | 2018-12-01 | 2018-12-7
1 | Dinosaur | 3 | 1 | 2019-02-01 | 2018-02-16
如何查询我的查询表,以便它只返回每个inventory_id 的最新return_date,这样我就没有不必要的数据(同一部电影之前签入和签出的日期)?
【问题讨论】:
-
请向我们展示这 3 个表中的示例数据,以便我们提供相关查询。