即使没有匹配MYsql中的条件,我也想获取最新记录。在mysql中获取最新的记录,但没有匹配条件
例如,我想根据产品类型分组选择2013年1月20日的数据,但它不符合此条件,因此它将获得这些产品类型的最新日期(2013-01-19)或2013-01-15)。
Coding:
Select date from tblproducttype where
date=(select max(date) from tblproducttype group by type) where date='2013-01-20'
Table product type
ID Type Date
1 2 2013-01-20
2 2 2013-01-20
3 2 2013-01-14
4 3 2013-01-19
5 4 2013-01-16
6 4 2013-01-13
结果应该是以下几点:
ID Type Date
1 2 2013-01-20
2 2 2013-01-20
4 3 2013-01-19
5 4 2013-01-16
对于结果,我想要的数据2013年1月20日与其他产品的最新数据结合起来。
最后,我们只能得到那些产品类型的最新日期。
如何在MYSQL中做到这一点?
问候。
请张贴您的企图。 –