mod(n,m)该函数返回n除以m的余数
需求:
分别找出所有影片 id 为奇数 ,偶数的影片,表名为cinema
id | movie | raing |
1 | war | 8.9 |
2 | science | 9.0 |
3 | irish | 7.3 |
4 | house card | 8.0 |
输出结果为
id | movie | raing |
1 | war | 8.9 |
3 | irish | 7.3 |
id | movie | raing |
2 | science | 9.0 |
4 | house card | 8.0 |
#输出表中id为奇数的列
select * from cinema where mod(id,2)=1
#输出表中id为奇数的列
select * from cinema where mod(id,2)=0