码迷,mamicode.com
首页 > 数据库 > 详细

数据库日期

时间:2019-03-18 21:14:41      阅读:273      评论:0      收藏:0      [点我收藏+]

标签:info   mes   att   sdn   stat   content   ogr   user   create   

<!--查按年询某个开发者下已上线的应用-->
<select id="selectAppByYearAndDevId" resultType="java.util.Map">
SELECT
app_name AS appName,
app_id As appId,
DATE_FORMAT(create_time, ‘%Y‘) AS date
FROM
aisv_g_app_info
WHERE
DATE_FORMAT(create_time, ‘%Y‘) = #{year}
AND is_del = 0
AND app_state = 5
AND developer_id = #{developerId}
</select>

<!--查按月询某个开发者下已上线的应用-->
<select id="selectAppByMonthAndDevId" resultType="java.util.Map">
SELECT
app_name AS appName,
app_id As appId,
DATE_FORMAT(create_time, ‘%Y-%m‘) AS date
FROM
aisv_g_app_info
WHERE
DATE_FORMAT(create_time, ‘%Y-%m‘) = #{month}
AND is_del = 0
AND app_state = 5
AND developer_id = #{developerId}
</select>

<!--查按周询某个开发者下已上线的应用-->
<select id="selectAppByWeekAndDevId" resultType="java.util.Map">
SELECT
app_name AS appName,
app_id As appId,
DATE_FORMAT(create_time, ‘%Y-%m-%d‘) AS date
FROM
aisv_g_app_info
WHERE
DATE_FORMAT(create_time,‘%Y-%m-%d‘) <![CDATA[ <= ]]>#{todayStr} AND
DATE_FORMAT(create_time,‘%Y-%m-%d‘)<![CDATA[ >= ]]>#{sevenDayBeforeStr}
AND is_del = 0
AND app_state = 5
AND developer_id = #{developerId}
</select>

<select id="selectListByUserOperationLogPage" resultMap="userOperationLogResult">

SELECT *
FROM
aisv_g_user_operation_log
<where>
1=1
<if test="param.userName!= null and param.userName !=‘‘">
and
user_name =#{param.userName}
</if>
<if test="param.userIp != null and param.userIp !=‘‘">
and
USER_IP =#{param.userIp }
</if>
<if test="param.operationType != null and param.operationType !=‘‘">
and
OPERATION_TYPE =#{param.operationType}
</if>
<if test="param.startdate != null and param.startdate !=‘‘">
and
OPERATION_TIME &gt;=#{param.startdate}
</if>
<if test="param.enddate != null and param.enddate !=‘‘">
and
OPERATION_TIME &lt;=#{param.enddate}
</if>
</where>
order by OPERATION_TIME DESC
limit #{page.begin},#{page.pageSize}
</select>

技术图片

@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDateTime transactionDate;

MySQL中大于等于小于等于的写法

由于在mybatis框架的xml中<= , >=解析会出现问题,编译报错,所以需要转译
第一种写法:

原符号 < <= > >= & ’ "
替换符号 &lt; &lt;= &gt; &gt;= &amp; &apos; &quot;
例如:sql如下:

unix_timestamp(target.mc_end_date)&lt;= unix_timestamp(#{MonthEndTime});unix_timestamp(target.mc_start_date) &gt;= unix_timestamp(#{MonthBeginTime})
  • 1

第二种写法:
大于等于

<![CDATA[ >= ]]>

小于等于

<![CDATA[ <= ]]>

例如:sql如下:

mc_end_date <![CDATA[ >= ]]> #{endTime} and  mc_start_date <![CDATA[ <= ]]> #{startTime}

数据库日期

标签:info   mes   att   sdn   stat   content   ogr   user   create   

原文地址:https://www.cnblogs.com/gavin-yao/p/10531698.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!