假设我有一个包含from_month(int, 1-12) 和to_month(int, 1-12) 列的表,然后我有另一个包含from(int, unix timestamp) 和to(int, unix timestamp) 列的表。
考虑到两边的年份边界,我将如何匹配from_month和to_month列包含我的from和时间戳的行?to
设想:
- 使用
from_monthas 11和to_monthas 2,有没有办法让我获得1383264000 的值和 1391212800from的值来匹配?to
然而同时:
- 使用
from_monthas 3和to_month8,有没有办法让我获得1362096000 的值和 1375315200from的值来匹配?to
说明:
- 我需要第二个表中的记录,其中两个时间戳的月份都在第一个表设定的范围之间。
- 另外,我可以从时间戳中获取月份,所以MySQL不需要解析它,但解决方案可能不受影响。