I have a following table:
+----+-----------------------+-----------------------+
| id | description | created_at |
+----+-----------------------+-----------------------+
| 5 | Game Of Thrones | 2017-03-14 17:45:12 |
| 4 | Breaking Bad | 2017-03-13 13:45:12 |
| 3 | Vikings | 2017-03-12 12:45:12 |
| 2 | How I Met Your Mother | 2017-03-10 18:45:12 |
| 1 | Mr. Robot | 2017-03-09 11:45:12 |
+----+-----------------------+ ----------------------+
Creating the table:
CREATE TABLE myTable(
int INTEGER PRIMARY KEY AUTOINCREMENT,
description TEXT,
created_at DATETIME)
This table is incremented every day at a random time. I would like a query to check if a new item has already been registered today. In this case I still would not have a record because today it is 2017-03-15 11:14:22
, so I could register a new item.
Given that it is possible to get the last registered item using the query:
select * from myTable order by created_at desc limit 1
How could you check if the last item was registered today based on the current time?