现在我正在创建一个在线游戏,其中列出了玩家的最后一次转会。
处理玩家历史的表具有 history_join_date 和 history_end_date 列。
当history_end_date被填满时,意味着球员离开了俱乐部,当它像默认值(0000-00-00 00:00:00)并且history_join_date有某个日期时,意味着球员加入俱乐部(在那个日期)。
现在,我有以下查询:
SELECT
player_id,
player_nickname,
team_id,
team_name,
history_join_date,
history_end_date
FROM
players
INNER JOIN history
ON history.history_user_id = players.player_id
INNER JOIN teams
ON history.history_team_id = teams.team_id
ORDER BY
history_end_date DESC,
history_join_date DESC
LIMIT 7
但是,此查询返回类似(使用上面的 PHP 过滤):
(22-Aug-2012 23:05): Folha has left Portuguese Haxball Team.
(22-Aug-2012 00:25): mancini has left United.
(21-Aug-2012 01:29): PatoDaOldSchool has left Reign In Power.
(22-Aug-2012 23:37): Master has joined Born To Win.
(22-Aug-2012 23:28): AceR has joined Born To Win.
(22-Aug-2012 23:08): Nasri has joined Porto Club of Haxball.
(22-Aug-2012 18:53): Lloyd Banks has joined ARRIBA.
PHP过滤器:
foreach ($transfers as $transfer) {
//has joined
if($transfer['history_end_date']<$transfer['history_join_date']) {
$type = ' has joined ';
$date = date("d-M-Y H:i", strtotime($transfer['history_join_date']));
} else {
$type = ' has left ';
$date = date("d-M-Y H:i", strtotime($transfer['history_end_date']));
}
如您所见,在转移订单中,日期没有被严格遵守(22-8 月 => 21-8 月 => 22-8 月)。
我在 SQL 中缺少什么?
问候!