DROP TABLE IF EXISTS diaries;
CREATE TABLE diaries (
id INT PRIMARY KEY AUTO_INCREMENT,
title TEXT,
created_at TIMESTAMP DEFAULT '2016-04-21 00:00:00',
updated_at TIMESTAMP DEFAULT '2016-04-21 00:00:00',
KEY (updated_at)
) DEFAULT CHARSET UTF8MB4;
INSERT INTO diaries (title, created_at, updated_at)
VALUES ("clear day", "2012-01-29 21:51:01", "2012-01-29 21:51:02");
INSERT INTO diaries (title, created_at, updated_at)
VALUES ("rainy day", "2012-01-30 01:23:45", "2012-01-30 01:23:46");
INSERT INTO diaries (title, created_at, updated_at)
VALUES ("cloudy day", "2012-01-31 08:32:10", "2012-01-31 08:32:11");
SELECT * FROM diaries;
id	title	created_at	updated_at
1	clear day	2012-01-29 21:51:01	2012-01-29 21:51:02
2	rainy day	2012-01-30 01:23:45	2012-01-30 01:23:46
3	cloudy day	2012-01-31 08:32:10	2012-01-31 08:32:11
SELECT * FROM diaries
WHERE updated_at BETWEEN "2012-01-29 00:00:00" AND "2012-01-31 00:00:00";
id	title	created_at	updated_at
1	clear day	2012-01-29 21:51:01	2012-01-29 21:51:02
2	rainy day	2012-01-30 01:23:45	2012-01-30 01:23:46
DROP TABLE diaries;
