不匹配的MySQL日期评估相等

时间:2018-03-20 13:35:44

标签: mysql

我有这个问题:

add_action('woocommerce_checkout_process', 'pinion_add_order');
function pinion_add_order($m, $a) {
    global $woocommerce;
    $address = array(
        'first_name' => 'Project Paid ',
        'last_name'  => $m
    );

    $order = wc_create_order();
    $order->add_product(($a == '100000' ? get_product('2858') : get_product('2859')), 1);
    $order->set_address($address, 'billing');
    $order->set_address($address, 'shipping');
    // $order->set_total($amount);
    $order->calculate_totals();
    $order->update_status("Completed", 'Imported order', TRUE);  

    return $order;
}

我得到了这条记录的结果:

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 中的 RecurringEventTime 与匹配记录中的 RecurringEventTime 不同时,为什么我得到匹配的记录令人费解。 OneTimeDateTime null ,因此无法匹配。

我错过了什么?

1 个答案:

答案 0 :(得分:0)

感谢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