如何使用两列获取过去的记录和即将到来的记录 [英] How to take past records and upcoming records using two columns
本文介绍了如何使用两列获取过去的记录和即将到来的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两列,使用这两列我必须从我的数据库中获取记录,
I have two columns, using this two columns i have to take the records from my DB,
- 过去的事件 ID
- 即将到来的事件 ID
过去的 eventId 表示哪些日期 (startDate & DueDate)
已经完成,我想记录
past eventId means which are the dates (startDate & dueDate)
already completed, i want to take the records
upcoming eventId 表示日期(startDate & DueDate)尚未完成,我想记录
upcoming eventId means which are the dates (startDate & dueDate) Not yet completed, i want to take the records
事件(表名)
eventId name startDate dueDate
1 A 2018-01-22 2018-01-22
2 B 2018-01-26 2018-01-27
3 C 2018-01-29 2018-01-31
我尝试过这样的 sql 查询
I tried sql query like this
SELECT * FROM events WHERE startDate >= '2018-01-30' AND dueDate <= '2018-01-30'
但是什么都没发生,我不知道如何编写 SQL 查询
But nothing is happening,I don't how to write SQL query
预期过去的 eventId
eventId
1
2
预计即将到来的 eventId
eventId
3
推荐答案
For Past Event:
SELECT * FROM events WHERE startDate <= '2018-01-30' AND DueDate <= '2018-01-30'
未来活动:
SELECT * FROM events WHERE DueDate >= '2018-01-30'
这篇关于如何使用两列获取过去的记录和即将到来的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文