Mybatis queries the time period of mysql, and mybatis queries mysql
The mapper file is written as follows: (fuzzy query, query time range)
<if test="com_name!=null and com_name!=''">and sc.com_name like CONCAT(CONCAT('%',#{com_name}),'%')</if><if test="check_begin_date!=null and check_begin_date!=''"><![CDATA[ and DATE_FORMAT(tcb.check_begin_date, '%Y-%m-%d') >= DATE_FORMAT(#{check_begin_date}, '%Y-%m-%d')]]></if><if test="check_end_date!=null and check_end_date!=''"><![CDATA[ and DATE_FORMAT(tcb.check_begin_date, '%Y-%m-%d') <= DATE_FORMAT(#{check_end_date}, '%Y-%m-%d')]]></if>
Mysql time period Query
Your request is between '2017-7-12 11:18:54 'and '2017-7-12 11:22:20 '.
Apparently, 11:18:46 and 11:22:22 are not between them. Why should they be included in the result set?
I also discuss the three upstairs
Select sum (csize) from table where cdtime between '2017-7-12 11:18:54 'and '2017-7-12 11:22:20'
--------------------------------------------
If there is another row in the table '2017-7-12 11:22:21 ', will the result set be 6 or 5?
This is clearly a problem with your description.
--------------------------------------------
Sorry, please give a clearer description
That is, if your nested query is used, the result set will be 5, not 6.
Is Mybatis the same as Mysql query statements?
Yes, yes.
You need to understand a concept. The statement we use when querying relational databases is SQL, which is the industrial standard supported by most relational database management systems, therefore, whether we query Mysql, Oracle, or other databases, it is the same SQL, whether it is java or C #.