Mysql query time period intersectionUsage scenariosThe database table has two fields starttime and endtime. Now given the time period (a, b), find the data that intersects with the time period (starttime, endtime). sql select * from TABLENAME where (starttime > a AND starttime < b) OR (starttime < a AND endtime > b) OR (endtime > a AND endtime < b) OR (starttime = a AND endtime = b); Mysql query whether two time periods intersectDatabase fields start_time, end_time Input fields a,b The firstSELECT * FROM test_table WHERE (start_time >= a AND start_time <= b) OR (start_time <= a AND end_time >= b) OR (end_time >= a AND end_time <= b) The secondSELECT * FROM test_table WHERE NOT ( (end_time < a OR (start_time > b) ) Both results are the same. 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:
|
<<: Using Zabbix to monitor the operation process of Oracle table space
>>: Detailed explanation of the use of this.$set in Vue
Detailed explanation of Linux LVM logical volume ...
Table of contents Basic Configuration Entry file ...
To master: localStorage, component encapsulation ...
1. System Configuration 1. Turn off sudo password...
Preface The server used by the blogger was purcha...
Copy code The code is as follows: <!DOCTYPE ht...
Table of contents Rendering Install Code Implemen...
Table of contents 1. Write an HTML, the first Vue...
1: Download MySql Official website download addre...
In actual projects, the up and down scroll bars a...
Why should we use CSS animation to replace JS ani...
This article shares the specific code for randomi...
Table of contents question analyze solve Replace ...
CentOS7 is used here, and the kernel version is [...
Tomcat7.0 sets virtual directory (1) Currently, o...