【问题标题】:Select elements with between between not work in SQLite选择介于之间的元素在 SQLite 中不起作用
【发布时间】:2018-12-04 19:03:58
【问题描述】:

下表包含我在 Android 上的 SQLite 数据库:

 >>>>> Dumping cursor android.database.sqlite.SQLiteCursor@9f3d273
0 {
   id=1543948972569
   relationItemID=-1
   degree=-1
}
1 {
   id=-1
   relationItemID=1543948972569
   degree=1
}
2 {
   id=1543948972569
   relationItemID=1543948978808
   degree=1
}
3 {
   id=1543948978808
   relationItemID=1543948972569
   degree=-1
}
<<<<<

SQLite 查询

SELECT id FROM itemsHierarchy 
WHERE id = 1543948972569 AND degree BETWEEN 0 AND -128

返回一个空游标,即使它应该找到第一个条目的id。 但是,如果我使用 '

SELECT id FROM itemsHierarchy WHERE id = 1543948972569 AND degree < 0;

是我做错了什么还是 SQLite 的问题?

【问题讨论】:

  • 你试过 BETWEEN -128 AND 0 吗?
  • @0X0nosugar 就是这样。谢谢。

标签: android sql database sqlite


【解决方案1】:

应该是——

    SELECT id 
    FROM itemsHierarchy 
    WHERE id = 1543948972569 
    AND degree BETWEEN -128 AND 0

【讨论】:

    猜你喜欢
    • 2011-02-11
    • 1970-01-01
    • 2015-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多