When you write a project recently, a data table inserts data with a special request:
Table structure properties are as follows: ID startime endtime value;
The requirement for inserting data is that the inserted time period starttime-endtime not between the starttime-endtime of an existing record.
For example: Add an existing record as follows
1 3:00 5:00 10;2 6:00 8:00 20;3 10:00 14:00 15;4 16:00 10:00 20
The inserted data cannot be 4:00-5:00, since 4:00 is already in the 3:00-5:00 time period and cannot be 2:00-9:00, because it contains the 3:00-5:00 and 6:00-8:00 time periods.
It's starting to feel a little bit of trouble, but it's good to think about it.
First excludes all endtime in the record that are less than the inserted St (newly inserted starttime) data. Compare with the rest of the dataset.
Then the starting time (ST) is greater than the StartTime less than the Endtime;
The end time ET (newly inserted endtime) is greater than starttime less than endtime;
The starting Time (ST) is less than starttime, and the end Time (ET) is greater than endtime;
The SQL statement for the last record that is not inserted in the MyBatis query is as follows
<select id= "Gettimetocompare" resulttype= "Time" parametermap= "Paramap" >
<![ cdata[
SELECT * FROM time where id = #{id} and Endtime > #{starttime} and
(StartTime <= #{starttime} and EN Dtime >= #{starttime}) or
(StartTime <= #{endtime} and Endtime >= #{endtime}) or StartTime >=
Time} and Endtime <= #{endtime})
]]>
</select>
Finally, the processing of a small MySQL exception is recorded. Recently after the Linux loaded with MySQL, if the remote connection with other visual tools, actually reported errorcode:13 error, see the meaning of the temporary directory does not have permissions. So I changed the TMP directory under Linux to 777 permissions, and I could access it. I hope I have a little help with the children's shoes.