我有三列f1、f2和f3
f1 f2 f3
1 3 5
5 7 3
...我的目标是选择f1:f2:f3关系大致为(+-2)号1:数字2:编号3的条目。
示例:
SELECT those rows where the relationship is roughly 5:7:4 -> Result 5 7 3.SELECT命令是什么样子的?
发布于 2017-12-09 17:58:31
也许有点像..。
-- test table and data
CREATE TABLE `t` (
`f1` INTEGER,
`f2` INTEGER,
`f3` INTEGER
);
insert into t ( f1, f2, f3 )
values (1,3,5),(5,7,3);
select * from t;
f1 f2 f3
1 3 5
5 7 3查询:
-- roughly 5:7:4 :: +/-1
select * from t
where (
( f1 between 4 and 6 )
and ( f2 between 6 and 8 )
and ( f3 between 2 and 4 )
) ;
-- result
f1 f2 f3
5 7 3杜德尔
-- roughly 5:7:4 :: +2
select * from t
where (
( f1 between 5 and 7 )
and ( f2 between 7 and 9 )
and ( f3 between 4 and 6 )
) ;
-- no rows returnedhttps://dba.stackexchange.com/questions/192762
复制相似问题