我有两个表:
m_sent user
uid, sent_date uid
我正在尝试获得一个date
值比今天更早的结果OR
的结果,而uid
表中的m_sent
根本没有任何行。 / p>
$today = (new DateTime())->setTime(0,0);
$midnight_today = $today->format('Y-m-d H:i:s');
$target_query = "SELECT `user`.uid FROM `user` LEFT JOIN `m_sent`";
$target_query .= " ON `user`.uid = `m_sent`.uid WHERE `user`.uid IS NOT NULL";
$target_query .= " AND (`m_sent`.sent_date < '$midnight_today' OR ***STUCK HERE***)";
$target_query .= " LIMIT 500;";
我基本上想要实现的目的是获得一个用户ID列表,其中一个是A)从未收到消息B)最近收到的消息是今天(00:00
)开始之前的时间。