【问题标题】:MySql How do I return last 60 days and multiple specific ids not within 60 days?MySql 我如何返回过去 60 天和不在 60 天内的多个特定 ID?
【发布时间】:2021-07-14 00:05:30
【问题描述】:

我正在尝试从过去 60 天内的所有预定约会中提取数据,以及针对不可用而对其有重复规则的特定多个 ID。

这些重复规则是 1、2、3、4、5、6 和 7 的 ID,它们在 60 天后没有返回,但我希望它们也被取消,这可能吗?

这是我到目前为止的查询,我相信为了实现这一点,我必须有另一个 select 语句?我想在一个查询中完成这一切。

select Id, Subject, StartTime, EndTime, Recurrence, RecurrenceType, CustomStyle, IsAllDay, RecurrenceStartDate, RecurrenceEndDate, RecurrenceRule, StartTimeZone, EndTimeZone, IsBlock, isSlotAvailable from schedule where date(DateCreated) BETWEEN NOW() - INTERVAL 60 DAY AND NOW()

【问题讨论】:

    标签: mysql


    【解决方案1】:

    如果您的意思是您希望在 60 天内和 (1,2,3,4,5,6,7) 中的 id 通过查询返回。您可以使用or 条件。
    or 条件下,如果数据通过任何测试,它将返回。

    select 
        Id, Subject, StartTime, EndTime, Recurrence, RecurrenceType, CustomStyle, IsAllDay, RecurrenceStartDate, RecurrenceEndDate, RecurrenceRule, StartTimeZone, EndTimeZone, IsBlock, isSlotAvailable 
        from schedule 
        where date(DateCreated) > (NOW() - INTERVAL 60 DAY)
        or Id in (1,2,3,4,5,6,7)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-29
      • 2016-09-13
      • 1970-01-01
      • 2021-05-19
      • 2012-03-09
      • 2016-04-03
      • 2018-02-15
      相关资源
      最近更新 更多