SQLite查询问题
我正在使用 sqlite db 做 android 项目,在选择查询中我有错误,即游标绑定异常(0),我的查询是:
Cursor c = myDB.rawQuery("SELECT * FROM COMPDETAIL WHERE city='Bangalore' AND service='Hospital';");
通过替换 AND 为 OR 它工作..
如果我想要 COMPDETAIL 通过多种条件...
提前致谢,
i am doing android project by using sqlite db ,in select query i have error that is cursor bound exception (0) ,my query is :
Cursor c = myDB.rawQuery("SELECT * FROM COMPDETAIL WHERE city='Bangalore' AND service='Hospital';");
by replacing AND by OR it working..
what am I suppose to do, if I want COMPDETAIL by multiple conditions...
Thanks in Advance,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 moveToFirst():
use moveToFirst():
您确定数据库中存在这样的行(城市 = '班加罗尔' 和服务 = '医院')吗?
AND
是 SQLite 中的 完全合法 关键字,没有理由它不会'不起作用,OR
会...除非没有行匹配这两个条件,并且您仍然尝试获取它 - 这将产生类似于越界的内容例外。Are you sure such row (with city = 'Bangalore' and service = 'Hospital') exists in your database?
AND
is perfectly legal keyword in SQLite, there's no reason it wouldn't work andOR
would... unless, there's no row matching both criteria, and you still try to fetch it - which will produce something along the lines of out of bounds exception.