本文介绍了SQLite3按数字范围选择字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在SQLite3中,说我有这个简单的表

$ p $ row $ value $ value $ $ b $(int)(float)(浮动)
1 15.3 20.2
2 17.8 30.5
3 15.8 25.3
4 16.1 48.0

我怎样才能选择那些行的值:

15.0> = value1

进一步
如何才能细化添加到第一个标准这也是
20.0> = value2

您的帮助是高度赞赏的

解决方案

第一个逻辑是不正确的,因为如果value1小于15,它也将小于16.5,但只是改变运算符:

从SimpleTable中选择*其中value1<< ; = 15.0和value1

也许你的意思是:

从SimpleTable中选择*其中value1 > = 15.0和value1

再次(考虑调整后的逻辑):

来自SimpleTable,其中value1> = 15.0且value1 = 20.0且value2

您可能希望添加order by子句,如果你想你的结果排序。


in SQLite3, say i have this simple table

rowid     value1    value2
(int)     (float)   (float)
1         15.3      20.2
2         17.8      30.5
3         15.8      25.3
4         16.1      48.0

How could I select those rows where the values are:
15.0 >= value1 <= 16.5 - effectively selecting rows 1,2 & 3

furtherhow can i refine adding to the first criteria this to ALSO20.0 >= value2 <= 37.0 - selecting then only row 1 & 3?

Your help is highly appreciated

解决方案

I believe your first logic is not correct, for if value1 is less than 15, it will also be less than 16.5, but just change the operators:

Select * from SimpleTable where value1 <= 15.0 and value1 <= 16.5;

Maybe you meant:

Select * from SimpleTable where value1 >= 15.0 and value1 <= 16.5;

Again (considering the adjusted logic):

Select * from SimpleTable where value1 >= 15.0 and value1 <= 16.5 and value2 >= 20.0 and value2 <= 37.0;

You might want to add and "order by" clause if you want your results sorted.

这篇关于SQLite3按数字范围选择字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 14:32
查看更多