当我们尝试对表中存储的日期值进行此类操作时,MySQL 会将日期值假设为数字并执行算术运算。
假设我们有一个名为“example”的表在“orderdate”列中有一个日期值,然后进行算术运算将澄清上述内容 –
mysql> select * from example; +------------+ | orderdate | +------------+ | 2017-05-25 | +------------+ 1 row in set (0.00 sec) mysql> select orderdate+10 from example; +--------------+ | orderdate+10 | +--------------+ | 20170535 | +--------------+ 1 row in set (0.00 sec) mysql> select orderdate*10 from example; +--------------+ | orderdate*10 | +--------------+ | 201705250 | +--------------+ 1 row in set (0.00 sec) mysql> select orderdate-10 from example; +--------------+ | orderdate-10 | +--------------+ | 20170515 | +--------------+ 1 row in set (0.00 sec) mysql> select orderdate/10 from example; +--------------+ | orderdate/10 | +--------------+ | 2017052.5 | +--------------+ 1 row in set (0.00 sec)原文来自:www.php.cn
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容