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
Configuration Instructions Linux system: CentOS-7...
This article shares the specific code of Vue+Webs...
Regarding the issue of MySQL remote connection, w...
Copy the following code to the code area of Drea...
Record the installation and configuration method ...
Copy code The code is as follows: .sugLayerDiv{ p...
System environment: Win10 64-bit MySQL version: m...
1. Search mysql in the browser to download and in...
When using XAML layout, sometimes in order to make...
Table of contents Load Balancing Load balancing c...
Experimental environment: 1. Three CentOS 7 serve...
Today's article mainly introduces the reload ...
After the user logs out, if the back button on the...
Using Navicat directly to connect via IP will rep...
This article uses examples to describe the common...