Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mysql timeline data gets the first three items of the same day's data.

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Create table data

CREATE TABLE `created_ info` (`id`bigint (20) NOT NULL AUTO_INCREMENT COMMENT 'ID', `pic_ id` varchar (64) DEFAULT NULL COMMENT' picture ID', `created_ time`datetime DEFAULT CURRENT_TIMESTAMP COMMENT 'creation time, PRIMARY KEY (`id`), KEY `pic_ id` (`pic_ id`) ENGINE=InnoDB AUTO_INCREMENT=3647 DEFAULT CHARSET=utf8 COMMENT=' picture table'

Add data omission

The first two pieces of data in the timeline

SELECT * FROM (SELECT *, @ num: = if (@ created_time = DATE_FORMAT (created_time,'% YMY% MMI% d'), @ num: = @ num + 1,1) as row_num,@created_time: = DATE_FORMAT (created_time,'% YMY% MMI% d') as axisTime FROM praise_infoorder by id desc) AS tempWHERE row_num < 3

Ps: take a look at the MySQL generation timeline

DROP PROCEDURE IF EXISTS pro_dim_date;tudou@GyyxCREATE PROCEDURE pro_dim_date (IN bdate DATE,IN edate DATE) BEGINDECLARE var DATE DEFAULT bdate;DECLARE evar DATE DEFAULT DATE_ADD (edate,INTERVAL 1 DAY); DECLARE bweek DATE;DECLARE eweek DATE;WHILE var4 THEN'is' ELSE'No 'END); SET var=DATE_ADD (var,INTERVAL 1 DAY); END WHILE;END

Call:

CALL pro_dim_date ('2005-01-01-01')

Results:

20131217 2013-12-17 17 2013 fourth quarter 2013 12 December 2013 December 121 Tuesday 51 week 51 (11 December to 23 December 2013 No 20131218 2013 12 18 18 2013 fourth quarter 2013 12 December 2013 12 December 2013 Wednesday 51 week 51 (12 December to 24 December 2013 no 20131219 2013 12 19 2013 4 quarter 2013 12 December 2013 Thursday, December 51 51 Week (13-25 December 2013 20131220 12-12-20 20 20131220 4 quarter 2013 12 December 2013 Friday 51 week 51 (14-26 December 2013 no 20131221 2013-12-21 2013 4-4 quarter 2013 12-12-21 2013 4-quarter 2013 12 December 2013 12 December 2013 Saturday 51 week 51 (15 December to 27 December 2013 is 20131222 2013 12-22 2013 4 quarter 201312 December 2013 December 12 Sunday 51 week 51 (December 16-December 28 is 20131223 2013-12-23 23 2013 fourth quarter 2013 12 December 2013 December 20 Monday 52 week 52 (17 December-29 December 2013 No 20131224 12-24 24 2013 4-quarter 2013 12 December 2013 12 December 2013 Tuesday 52 week 52 (18 December to 30 December 2013 No no 2013 1225 2013-12-25 2013 Week 52 on Wednesday, December 12, 2013, fourth quarter, 2013 (19-31 December, no 20131226 2013-12-26 26, 4-quarter 2013, Thursday, December 12, 2013, week 52, week 52 (20 December to 1 January 2013 No no 2013 1227 2013 12-27 2013 4 quarter 2013 12 December 2013 Friday 52 week (21 December-January 1, 2013) 2 No 20131228 2013-12-28 28 2013 fourth quarter 2013 December 12 2013 December 5 Saturday 52 week 52 (December 22-January 3 is 20131229 2013-12-29 29 2013 fourth quarter 2013 12 December 2013 December 6 Sunday 52 week 52 (December 23 to January 4 is

Table structure:

CREATE TABLE `dim_ date` (`date_ id` int (11) NOT NULL COMMENT '20110512, `date_ name` varchar (16) DEFAULT NULL COMMENT' 2011-05-12, `date_of_ month` int (11) DEFAULT NULL COMMENT'12, `year_ id` int (11) DEFAULT NULL COMMENT '2011, `year_ name`varchar (16) DEFAULT NULL COMMENT' 2011', `quarter_ id`int (11) DEFAULT NULL COMMENT '2mm, `quarter_ name` varchar (16) DEFAULT NULL COMMENT' 2Q' `month_of_year_ id` int (11) DEFAULT NULL COMMENT '5years, `month_ name` varchar (16) DEFAULT NULL COMMENT' May', `month_of_year_ name` varchar (16) DEFAULT NULL COMMENT 'May 2011', `month_of_year_ id` int (11) DEFAULT NULL COMMENT '201105, `week_ id` int (11) DEFAULT NULL, `week_ name`varchar (16) DEFAULT NULL, `week_of_year_ id` int (11) DEFAULT NULL, `week_of_year_ name` varchar (32) DEFAULT NULL `is_ weekend` enum ('No', 'Yes') DEFAULT NULL COMMENT 'weekend', PRIMARY KEY (`weekend id`), KEY `ix_dim_date_date_ name` (`date_ name`), KEY `ix_dim_date_month_ id` (`month_ id`), KEY `ix_dim_date_year_ id` (`year_ id`), KEY `ix_dim_date_quanter_ id` (`quarter_ id`), KEY `ix_dim_date_week_of_year_ id` (`week_of_year_ id`) `week_of_year_ name`) ENGINE=MyISAM DEFAULT CHARSET=latin1

Summary

The above are the first three items of the Mysql timeline data that the editor introduced to you to get the data on the same day. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to the website!

If you think this article is helpful to you, you are welcome to reprint it, please indicate the source, thank you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report