简体   繁体   English

如何从 MySql 中的表中获取 C# 中即将到来的约会?

[英]How do I get upcoming appointments in C# from a table in MySql?

I need a way to populate a reminder in my winforms application of appointments that are coming up within the next 15 minutes of a user logging in. Every SQL query I've tried doesn't give me what I need.我需要一种方法来在我的 winforms 应用程序中填充用户登录后 15 分钟内即将到来的约会提醒。我尝试过的每个 SQL 查询都没有给我我需要的东西。 I am a noob, so please don't be too harsh.我是菜鸟,所以请不要太苛刻。 I don't have a table that gives me login times, only the appointment table with start date.我没有提供登录时间的表格,只有带有开始日期的约会表格。

SELECT DISTINCT start FROM appointment WHERE start < NOW() - INTERVAL 15 MINUTE AND NOT EXISTS (SELECT * FROM appointment WHERE start = NOW() - INTERVAL 15 MINUTE ) SELECT 从约会开始的不同开始<现在() - 间隔 15 分钟且不存在(选择 * 从约会开始 = 现在() - 间隔 15 分钟)

I'm not sure exactly what your criteria are regarding login time and when you would check, but you need a where clause something like:我不确定您的登录时间和检查时间的标准是什么,但您需要一个 where 子句,例如:

WHERE start BETWEEN NOW() and NOW() + INTERVAL 15 MINUTE

Your use of "- INTERVAL 15 MINUTE" is looking in the past, not the future.您对“- INTERVAL 15 MINUTE”的使用是在回顾过去,而不是展望未来。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM