Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以,我有一个带有某个整数的变量。我们称之为$num。我想做的是检查一个名为nums的表,其中我的值介于或等于$num-2和$num+2但不等于$num。
从数学上讲,这个范围就像[$num-2,$num[ ; ]$num,$num+2]。
SELECT num FROM nums WHERE ...
我知道这是基本查询,但我现在有点困惑。提前致谢。
SELECT ... ... WHERE nums (BETWEEN ($num - 2) AND ($num + 2)) AND (nums <> $num)