您如何从表格中获得下一个即将到来的日期? [英] How do you get the next upcoming date from a table?
本文介绍了您如何从表格中获得下一个即将到来的日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在建立棒球网站.在页面的一侧,我想显示有关即将推出的游戏的信息.我正在使用mysql ver. 5.0.45.我的表是这样构建的:
I am currently working on building a baseball website. On one side of the page I want to display information on the next upcoming game. I am using mysql ver. 5.0.45. My table is built as so:
对手,日期,时间,得分
opposingTeam, date, time, score
- 日期采用mysql日期格式(yyyy-mm-dd)
- 我找到了datediff(date1,date2)命令,并尝试了一点运气
我尝试了以下查询:
SELECT *
FROM schedule
WHERE MIN(DATEDIFF(CURDATE(),date))
- 但是这给了我一个错误,因为我在错误地使用了
MIN()
函数 - 我对mysql还是很陌生,我似乎无法弄清这一点
- But this gives me an arror because I am using the
MIN()
function wrong - I am still pretty new to mysql and I just can not seem to figure this out
推荐答案
如果要显示下一场比赛(包括今天),可以使用以下内容:
If you want to display the next game (including today) you can use the following:
SELECT * FROM `schedule` WHERE `date` >= CURDATE() ORDER BY `date` LIMIT 1;
如果要显示所有即将发布的游戏,请使用:
If you want to display all upcoming games use:
SELECT * FROM `schedule` WHERE `date` >= CURDATE() ORDER BY `date`;
这篇关于您如何从表格中获得下一个即将到来的日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文