当前位置:数据库 > SQLite >>

关于SQLite 中的查询语句

public class listview extends ListActivity { //int id,sign; String id,sign,name,latitude,longitude,description; int signValue; protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.listview); Intent searchTolistview = getIntent(); signValue = searchTolistview.getIntExtra("sign", signValue); System.out.println(signValue+""); dataBaseHelper hereami_helper = new dataBaseHelper(listview.this, "hereamiTest"); SQLiteDatabase hereami_sqlite = hereami_helper.getReadableDatabase(); Cursor cursor = hereami_sqlite.query("hereami_table", new String[] {"sign","name" }, "sign=signValue", null, null, null, null); 我从别的Activity中传过来个整数 存在signValue中了 想用这个值在数据库中查询 其中sign是表中的一列 我就要查传过来的signValue和sign一样值的名字name 如何操作?!
答案:不知道你这是什么语言。
如果有SQLiteDatabase的话,
那么肯定有SQLitePreparedStatement
你用这个东西,设置参数sign=?,然后bind上signValue,执行就应该可以了。
其他:如果是SQL语句的话,应该是这样:
假设你查询语句的存储字符串是s
sprintf(s, "SELECT name FROM hereami_table WHERE sign=%u", signValue);
然后把s作为查询语句输入就可以
但是你的sqlite是封装过的,不知道具体输入参数是什么样子 

上一个:在C#里面 怎么设置Sqlite的相对的连接字符串?
下一个:PHP sqlite 编码问题

Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,