开发者

MySQL ORDER BY date and team

I would like to order by date and then team in a MySQL query. It should be开发者_StackOverflow something similar to this:

SELECT * FROM games ORDER BY gamedate ASC, team_id

AND it should output something like this:

2010-04-12 10:20 Game 1 Team 1
2010-04-12 11:00 Game 3 Team 1
2010-04-12 10:30 Game 2 Team 2
2010-04-14 10:00 Game 4 Team 1

So that Team 1 is under each other on the same date, but separate on a new date


Assuming that gamedate is a date field rather than a datetime field, that should work. If it's a datetime field, you would have to use something like date(gamedate) as the first ordering predicate:

SELECT * FROM games ORDER BY date(gamedate) ASC, team_id ASC
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜