我们可以将算术运算符(+、-、*、/)与 INTERVAL 关键字的单位值一起使用,如下 -
mysql> Select date('2017-10-22' + INTERVAL 2-2 Year) AS 'Date After (2-2)Years'; +------------------------+ | Date After (2-2) Years | +------------------------+ | 2017-10-22 | +------------------------+ 1 row in set (0.00 sec)
mysql> Select date('2017-10-22' + INTERVAL 2*2 Year) AS 'Date After (2*2)Years'; +------------------------+ | Date After (2*2) Years | +------------------------+ | 2021-10-22 | +------------------------+ 1 row in set (0.00 sec)
mysql> Select date('2017-10-22' + INTERVAL 2/2 Year) AS 'Date After (2/2) Years'; +------------------------+ | Date After (2/2) Years | +------------------------+ | 2018-10-22 | +------------------------+ 1 row in set (0.00 sec)
以上就是如何在 MySQL 中将算术运算符(+、-、*、/)与 INTERVAL 关键字的单位值一起使用?的详细内容,更多请关注php中文网其它相关文章!
已抢141267个
抢已抢4791个
抢已抢7599个
抢已抢21997个
抢