我有这个问题:
select w.EventName, w.EventLocation, CONCAT(CURDATE(), ' ', w.RecurringEventTime) AS RecurringEventTime, w.OneTimeDateTime
from EventClickIns eci
join WebEvents w
on eci.WebEventID = w.ID
where eci.UserID = 493
and eci.WebEventID <> 10
and eci.InvitationID <> 175
and date(eci.ClickInDate) = date(now())
and (RecurringEventTime = '2018-03-19 12:00:00' OR w.OneTimeDateTime = '2018-03-19 12:00:00')
limit 1
我得到了这条记录的结果:
EventName EventLocation RecurringEventTime OneTimeDateTime
========================================================================
Evt ABC 123 Anystreet 2018-03-20 12:00:00 NULL
当我的where clause
中的RecurringEventTime与匹配记录中的RecurringEventTime不同时,为什么我得到匹配记录令人困惑。 OneTimeDateTime为null,因此无法匹配。
我错过了什么?
感谢Sam和Solarflare的提示,我明白了:
select w.EventName, w.EventLocation, CONCAT(CURDATE(), ' ', w.RecurringEventTime) AS RecurringEventTime, w.OneTimeDateTime
from EventClickIns eci
join WebEvents w
on eci.WebEventID = w.ID
where eci.UserID = 493
and eci.WebEventID <> 10
and eci.InvitationID <> 175
and date(eci.ClickInDate) = date(now())
and (CONCAT(CURDATE(), ' ', w.RecurringEventTime) = '2018-03-19 12:00:00' OR w.OneTimeDateTime = '2018-03-19 12:00:00')
limit 1