8
mysql中timestamp数据批量加减
source link: http://saiya.xyz/2021/01/12/mysql%E4%B8%ADtimestamp%E6%95%B0%E6%8D%AE%E6%89%B9%E9%87%8F%E5%8A%A0%E5%87%8F/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
做人还是要有梦想的,万一实现了呢。
mysql中timestamp数据批量加减
业务需求,mysql数据库中timestamp类型的到期时间统一延后一年。
以下是查询时将结果延后一年。
SELECT `id`, DATE_ADD(`end_time`, INTERVAL 1 YEAR) AS endTime FROM `parking_space` WHERE `parking_id` LIKE '2c9f903275cfaaab0175ea1af0256780'
id endTime
297e1cb576ccbebf0176ccc084aa0000 2022-12-30 23:59:59
297e1cb576ccbebf0176ccc08e5c0001 2022-12-30 23:59:59
297e1cb576ccbebf0176ccc08f410002 2022-12-30 23:59:59
297e1cb576ccbebf0176ccc090330003 2022-12-30 23:59:59
直接更新数据库数据(慎重使用)
UPDATE `parking_space` SET `end_time` = DATE_ADD(`end_time`, INTERVAL 1 YEAR) WHERE `parking_id` LIKE '2c9f903275cfaaab0175ea1af0256780'
mysql时间数据函数操作参考
https://www.w3school.com.cn/sql/func_date_add.asp
发布于 2021年1月12日作者 Elvis分类 开发笔记标签 mysql
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK