pet*_*awn 1 sqlite android android-sqlite
我正在尝试仅查询表中的第一个数据.
Cursor img_cursor = db.query(
IMAGE_URL_TABLE_NAME,
new String[]{"small_img_url" , "large_img_url"},
null",
null, null, null, null);
Run Code Online (Sandbox Code Playgroud)
有人能告诉我如何实现只从表中检索第一个数据的查询吗?
我想我解决了答案:
Cursor img_cursor = db.query(
IMAGE_URL_TABLE_NAME,
new String[]{"small_img_url" , "large_img_url"},
null",
null, null, null, null , "1");
Run Code Online (Sandbox Code Playgroud)
我limit 1先用过,但应用程序崩溃了.只有当我将数字作为String遗嘱传递时才有效.当我们使用limit参数时,查询有8个参数.
limit 1
来自文档:
public Cursor query (boolean distinct, String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit)
Run Code Online (Sandbox Code Playgroud)
所以,把你的最后一个论点设为"限制1".
Cursor img_cursor = db.query(
IMAGE_URL_TABLE_NAME,
new String[]{"small_img_url" , "large_img_url"},
null,
null, null, null, "limit 1");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
891 次 |
| 最近记录: |