Center6.5 MySQL installation, configuration, optimization My

2023-01-23   ES  

Because the design date format is different from the various data types in the database, the VARCHAR type is selected to store the date, which corresponds to the Java String type. Therefore, the SQL statement used in the Mapper.xml file can be used.date_format (field name, “Date Format”), this is the method of MySQL database. hereWhat needs to be noted is that “less than” should be used “& lt;” at the time of the comparison date

<if test="params.taskName != null">
        and task_name like '%${params.taskName}%'
          <if test="params.keyWord != null">
	        or task_name like '%${params.keyWord}%'
	        or task_describe like '%${params.keyWord}%'
      <if test="params.publishTime1 != null">
        and DATE_FORMAT(publish_time,'%Y-%m-%d %H:%i') >= DATE_FORMAT(#{params.publishTime1},'%Y-%m-%d %H:%i')
      <if test="params.publishTime2 != null">
        and DATE_FORMAT(publish_time,'%Y-%m-%d %H:%i') &lt;= DATE_FORMAT(#{params.publishTime2},'%Y-%m-%d %H:%i')
      <if test="params.endTime1 != null">
        and DATE_FORMAT(end_time,'%Y-%m-%d %H:%i') >= DATE_FORMAT(#{params.endTime1},'%Y-%m-%d %H:%i')
      <if test="params.endTime2 != null">
        and DATE_FORMAT(end_time,'%Y-%m-%d %H:%i') &lt;= DATE_FORMAT(#{params.endTime2},'%Y-%m-%d %H:%i')
      <if test="params.keyWord != null and params.taskName == null">
        and task_name like '%${params.keyWord}%'
	        or task_describe like '%${params.keyWord}%'

By the way, record a question:

KEYWORD is not a field in the database. When the parameter is valuable, the query target is task_name and task_describe. Here you need to pay attention to use or use or OR.


Related Posts

springmvc04 custom data type converter

SDK version and API Level corresponding table seveny

Android Ijkplayer compile and import iJKPlayer-EXAMPLE example

java read Excel 2007.xlsx file

Center6.5 MySQL installation, configuration, optimization My

Random Posts

IDEA configures ECMAScript6 syntax to ECMAScript5 to improve JS coding efficiency

Tomcat configuration https

Master this posture, girlfriend no longer talks about

MyBatis-Plus Insert Times Error Order

MySQL-Case WHEN according to the field value