mysql between boundary rangeThe range of between is inclusive of the boundary values on both sides
The range of not between does not include the boundary value
SELECT * FROM `test` where id BETWEEN 3 and 7; Equivalent to SELECT * FROM `test` where id>=3 and id<=7; ----------------------------------------------------------- SELECT * FROM `test` where id NOT BETWEEN 3 and 7; Equivalent to SELECT * FROM `test` where id<3 or id>7; Note the issue of mysql between date boundariesBoundary issues:mysql, between start date AND end date includes the start date and excludes the end date For example:BETWEEN '2018-01-22' AND '2018-01-30' The start date is 2018-01-22 00:00:00.0 and ends at 2018-01-29 23:59:59.59 CREATE_DATE in the table is varchar(21) DEFAULT NULL COMMENT 'time', The value stored in CREATE_DATE is: year-month-day hour:minute:second:0 For example: 2018-01-29 23:45:35.0 SELECT * FROM Test a WHERE a.CREATE_DATE BETWEEN '2018-01-22' AND '2018-01-30' ORDER BY a.CREATE_DATE desc SELECT * FROM TABEL a WHERE a.CREATE_DATE BETWEEN '2018-01-22' AND '2018-01-30' ORDER BY a.CREATE_DATE desc 2018-01-29 23:45:35.0 20180129 2018-01-29 23:45:33.0 20180129 2018-01-29 00:10:58.0 20180129 2018-01-29 00:10:45.0 20180129 2018-01-28 23:42:23.0 20180128 2018-01-28 23:39:39.0 20180128 SELECT * FROM TABEL a WHERE a.CREATE_DATE BETWEEN '2018-01-22' AND '2018-01-29' ORDER BY a.CREATE_DATE desc 2018-01-28 23:42:23.0 20180128 2018-01-28 23:39:39.0 20180128 2018-01-28 00:13:22.0 20180128 2018-01-28 00:13:19.0 20180128 2018-01-27 23:23:02.0 20180127 2018-01-22 00:09:59.0 20180122 2018-01-22 00:09:56.0 20180122 2018-01-22 00:01:53.0 20180122 Other problems encountered: Another table test2 has a field for saving time: `REPORTTIME` varchar(45) DEFAULT NULL, The value stored in this field is: Example 1:select * from bips_hpd_helpdesk a WHERE str_to_date(from_unixtime(a.REPORTTIME,'%Y-%m-%d'),'%Y-%m-%d') BETWEEN '2018-01-16' AND '2018-01-27' ORDER BY from_unixtime(a.REPORTTIME,'%Y-%m-%d') DESC ; Result 1: From the results, we can see that the data for the 27th was obtained. It may be that the processing time does not include hours, minutes, and seconds. Example 2:select * from bips_hpd_helpdesk a WHERE str_to_date(from_unixtime(a.REPORTTIME,'%Y-%m-%d'),'%Y-%m-%d') BETWEEN str_to_date('2018-01-16','%Y-%m-%d') AND str_to_date('2018-01-27','%Y-%m-%d') Result 2: Found the problem: When converting millisecond values to time, I found that the millisecond values saved here do not save the hours, minutes, and seconds: from_unixtime(a.REPORTTIME,'%Y-%m-%d') AS reportTime,a.REPORTTIME, str_to_date(from_unixtime(a.REPORTTIME,'%Y-%m-%d'),'%Y-%m-%d %h:%i:%s') AS reportTime22 FROM test a WHERE str_to_date(from_unixtime(a.REPORTTIME,'%Y-%m-%d'),'%Y-%m-%d %h:%i:%s') BETWEEN str_to_date('2018-01-16','%Y-%m-%d %h:%i:%s') AND str_to_date('2018-01-27 %h:%i:%s','%Y-%m-%d') #subdate(curdate(),date_format(curdate(),'%w')-1) AND subdate(curdate(),date_format(curdate(),'%w')-8) ORDER BY from_unixtime(a.REPORTTIME,'%Y-%m-%d') DESC; Viewed time value: The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. You may also be interested in:
|
<<: CSS implements the web component function of sliding the message panel
>>: Do you know how to use Vue to take screenshots of web pages?
Table of contents 1. Introduction 1.1 Babel Trans...
In the vue scaffolding, we can see that in the ne...
Table of contents this Method In the object Hidde...
load Request Success Request failed Click cmd and...
This article uses javascript+CSS to implement the...
This article introduces the installation of Windo...
There are two types of web page box models: 1: Sta...
The cascading drop-down menu developed in this ex...
mysql-5.7.17.msi installation, follow the screens...
Table of contents What is a trigger Create a trig...
Business scenario: The visitor's visit status...
In the process of product design, designers always...
1. To develop web responsively, the page must ada...
To create a flex container, simply add a display:...
This article example shares the specific code of ...