你们能帮我用同一张表更新这个表吗?我的table:
id | pass_date | daydiff |
1 | 2018-04-20 14:49:24 | |
2 | 2018-04-21 14:49:24 | |
3 | 2018-04-20 14:49:24 | |
我可以选择表来计算日差
SELECT id, DATEDIFF(pass_date , CURDATE()) as daydiff FROM users
结果:
id | daydiff |
1 | 3 |
2 | 2 |
3 | 3 |
我想做的是像这样更新daydiff列:
id | pass_date | daydiff |
1 | 2018-04-20 14:49:24 | 3 |
2 | 2018-04-21 14:49:24 | 2 |
3 | 2018-04-20 14:49:24 | 3 |
1条答案
按热度按时间rekjcdws1#
好吧,你可以这样做