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
Text truncation with CSS Consider the following c...
This article example shares the specific code of ...
Table of contents 1. props/$emit Introduction Cod...
Table of contents LAMP architecture 1.Lamp Introd...
Table of contents introduction Indexing principle...
Table of contents 1. Introduction 2. Solution 2.1...
When talking about the screen reading software op...
> Deploy MySQL 5.7 cluster master & slave ...
MySQL allows you to create multiple indexes on a ...
Table of contents 1. Define object methods 2. Def...
Table of contents 1. Teleport usage 2. Complete t...
Code first, then text Copy code The code is as fol...
1. Use Centos image to build local yum source Sin...
Recently, due to business reasons, I need to acce...
This article shares the specific code for JavaScr...