SELECT 记录 MySQL:在日期 + 1 之间 [英] SELECT records MySQL: between date + 1

查看:45
本文介绍了SELECT 记录 MySQL:在日期 + 1 之间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我想选择两个日期之间的所有记录加上该日期之前的一条记录和该日期之后的一条记录?所有记录均按日期排序.

Say I want to SELECT all records between two dates plus one record before and one record after that date? All records are ordered by date.

推荐答案

  (select * from t where date < start_date order by date desc limit 1)
  union (select * FROM t WHERE date between start_date and end_date)
  union (select * from t where date > end_date order by date asc limit 1)

这篇关于SELECT 记录 MySQL:在日期 + 1 之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆