mysql - SQL整数查询,查找+/- 1以内的整数

标签 mysql sql

如果我想运行像这样的 SQL 语句

"SELECT integername from tblintegerlist where integerlist ..."

我有一个数字列表,例如

integername
1
2
3
4
5

所以我想要 +/- 1 的搜索结果,因此对于“4”我会得到第 3、4、5 行作为结果。

最佳答案

如果我理解正确的话

where integername >= n-1 AND integername <= n+1

关于mysql - SQL整数查询,查找+/- 1以内的整数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6238230/

相关文章:

用于优化的 MySQL 哈希索引

mysql - 如果在 SQL 中结果为空,如何返回列值?

mysql - 如何通过 CASE 语句中的变量对结果进行排序

mysql - Mysql中innodb_flush_log_at_trx_commit的理解

SQL查询结合存在检查和条件检查

MySQL 从多行中选择 1 行

python - 赋值之前引用的局部变量 'price_end'

c# - SQL Server 表中的并行插入/更新

MYSQL员工及家属

sql - 如何将日期与当前时间一起保存到数据库中?