简体   繁体   中英

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.

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?

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.
in or condition if the data pass any test it will return.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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