选择除以2后的余数(模)为1的行? [英] Selecting rows where remainder (modulo) is 1 after division by 2?

查看:168
本文介绍了选择除以2后的余数(模)为1的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

选项中有一个包含整数的列.我只想在该值%2 = 1时选择该行.

There is a column in options that hold an integer. I want to select the row only if that value % 2 = 1.

我知道这可以在2个查询中完成,但是有可能在1个查询中完成吗?

I know this can be done in 2 queries but is it possible to do it in 1?

推荐答案

使用百分号作为模数的MySQL,SQL Server,PostgreSQL,SQLite支持:

MySQL, SQL Server, PostgreSQL, SQLite support using the percent sign as the modulus:

WHERE column % 2 = 1

对于Oracle,您必须使用 MOD函数:

For Oracle, you have to use the MOD function:

WHERE MOD(column, 2) = 1

这篇关于选择除以2后的余数(模)为1的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆