简体   繁体   English

MySql 如何返回过去 60 天和多个不在 60 天内的特定 ID?

[英]MySql How do I return last 60 days and multiple specific ids not within 60 days?

I'm trying to pull data from all scheduled appointments within the last 60 days and specific multiple ids that have recurrence rules on them for unavailability.我正在尝试从过去 60 天内的所有预定约会和特定的多个 ID 中提取数据,这些 ID 上有重复规则以防止不可用。

These recurrence rules are ids of 1,2,3,4,5,6 and 7 that don't get returned from the 60 days but I want them pulled as well is this possible?这些重复规则是 1、2、3、4、5、6 和 7 的 ID,它们在 60 天内不会返回,但我也希望它们也被拉出,这可能吗?

Here is my query so far I believe in order to achieve this I'll have to have another select statement?到目前为止,这是我的查询,我相信为了实现这一点,我必须有另一个选择语句? I want to accomplish this all in one query.我想在一个查询中完成这一切。

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()

if you means you want both in 60 days and id in (1,2,3,4,5,6,7) return by query.you can use or condition.如果你的意思是你想要在 60 天内和 id in (1,2,3,4,5,6,7) 通过查询返回。你可以使用or条件。
in or condition if the data pass any test it will return.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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM