private static String sql1="create table user(
_id integer primary key autoincrement,
name varchar(20),
pwd varchar(20))";
private static String sql2="create table account_book("+
"_id integer primary key autoincrement,"+
"name varchar(20) not null,"+
"user_id references user(_id) not null,"+
"cash double ,"+
" disposit_card double,"+
" credit_card double,"+
"alipay double )";
private static String sql3= " create table payin("+
" _id integer primary key autoincrement,"+
"account_id references account_book(_id) not null,"+
"type varchar(20),"+
"use varchar(20),"+
"date,"+
"count integer(20),"+
"qianbao varchar(20),"+
"beizhu varchar(30) )";
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL(sql1);
db.execSQL(sql2);
db.execSQL(sql3);
}
以上是建表語句。
以下根據user_id 在account_book表中查詢時返回的cursor中沒有記錄getcount=0
根據account_id在payin表中查詢也是一樣的情況。
下面是我的查詢語句:
Cursor cursor=database.query("account_book",new String[]{"_id"},"user_id=?", new String[]{user_id+""}, null, null, null);
Cursor cursor=database.query("payin",new String[]{"_id","type","use","count","qianbao","beizhu"}, "account_id=?and type=?", new String[]{account_id.toString(),type}, null, null, "_id");
請大神解惑,拜托了
本人已經解決了,謝謝大家熱心回答了。