如下查询Stringsql="selectsid,snamefromstudentwheresid=?";Cursorcursor=db.rawQuery(sql,new... 如下查询
String sql = "select sid,sname from student where sid = ? ";
Cursor cursor = db.rawQuery(sql, new String[]{'1'});
但是通过sqlite命令查看是有一行数据的,最后发现在命令中执行
执行 select sid,sname from student where sid = ‘1’没有结果
执行 select sid,sname from student where sid = 1有结果
于是在网上查了一下将代码中改为
String sql = "select sid,sname from student where sid = cast( ? as int) "; 有结果

因此特别想问一下这是什么情况
我一直都觉得我语文没过关,读了好几遍似乎还可以在读几遍

使用db.raw.query()时,sql语句的占位符 要根据数据类型 将参数转换一下,对不对?
api上有这么一句:The values will be bound as Strings.(好像是说值是作为字符串)

网上很多例子都是直接使用,没有对参数类型转换,这点我也很不解
整体确实要被当做字符串,这个理解是正确的。

但是其中使用到变量或者参数,要根据其数据类型产生相应的定界符,不然这个sql字符串被当做语句执行时就会出现数据类型不匹配了。
我不是弄android的只是自己想学一下,过了这么就才回实在抱歉
这个也没结果
Cursor c = db.query("student", projection, selection, selectionArgs, null, null, null)
selection={"sid = ?"}
selectionArgs={"2"}
字数有限其他的节省了,是不是有什么地方我理解错了