mysql 获取偶数行&&奇数行

场景

  • 通过命令行更新一波测试数据,奇数行和偶数行有所区分

分析

mod函数的官方文档
MOD(N,M), N % M, N MOD M

Modulo operation. Returns the remainder of N divided by M.
返回N除以M之后的余数

解决

update `statistic` set date='20180905' where mod(id, 2)=0;
update `statistic` set date='20180906' where mod(id, 2)=1;

猜你喜欢

转载自blog.csdn.net/cominglately/article/details/82493893