如何格式化的WHERE子句和“?”在一个SQLite查询? [英] How to format the WHERE clause and '?' in a SQLite query?

查看:140
本文介绍了如何格式化的WHERE子句和“?”在一个SQLite查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用内置的SQLite的功能,我不知道如何格式化查询。我如何格式化,其中子句和 ,可以去那里?

I'm trying to use the built in SQLite functions and I'm not sure how to format a query. How do I format the WHERE clause and the ? that can go in there:

column [] = {"name"};
selectionArg [] = {"john};
Select name from mytable where id = "john"

db.query(mytable, column, id = ?, selectionArg, null,null,null);

我不是在那里我可以测试它,但我想要得到它在第一时间。我不知道,如果必须是或者是 ID = +?等等。我似乎无法找到格式的任何实例。

I'm not to where I can test it, but I'm trying to get it right the first time. I'm not sure if the ? needs to be "?" or if it is id = + "?" and so forth. I can't seem to find any examples of the format.

推荐答案

有关查询:

select name from mytable where id = "john"

使用

(SQliteDatabase) db.query(
    "mytable" /* table */,
    new String[] { "name" } /* columns */,
    "id = ?" /* where or selection */,
    new String[] { "john" } /* selectionArgs i.e. value to replace ? */,
    null /* groupBy */,
    null /* having */,
    null /* orderBy */
);

这篇关于如何格式化的WHERE子句和“?”在一个SQLite查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆