选择除以 2 后余数(模)为 1 的行? [英] Selecting rows where remainder (modulo) is 1 after division by 2?
本文介绍了选择除以 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屋!
查看全文