SQLite - 从表中检索一组名称

问题描述:

我已经在SQLite数据库中存储了一些名称和分数,如截图所示。SQLite - 从表中检索一组名称

enter image description here

数据库名称:database

表名:table

表中字段表:

* Name 

* Score 

我可以从数据库中检索的name对于给定的score

我的要求是,如果我给范围值10,它应该被添加到score,我应该得到在给定范围内的names的集合。

例如,如果范围值是10,和给定score是120,我应该得到的一组names范围120之间,以130

所以,结果应该是迈克,拉吉和萨姆斯。

我该如何做这项工作?有没有任何疑问?提前致谢。

+0

这是SQLite的,MySQL的,或两者兼而有之? – Blorgbeard 2012-02-15 12:32:36

当然,怎么样:

select name from table 
where score >= @score and score <= (@score + @range) 

替代语法:

select name from table 
where score between @score and (@score + @range) 

select * from my_table where score >= start and score <= start + range 

SELECT Name FROM table 
WHERE Score >= @yourScore and Score <= (@yourScore + @delta)