androidmysql条件查询语句_AndroidStudio中litepal数据库多
条。。。
备份
模糊查⽤关键字like和%
1.where中⽤and连接,condition⽤?,后⾯依次写出来
if(!mymajor.equals("null")){//需要查询分数
Listdatas=DataSupport.where("classes=? and location =? and major like ?",
myclasses,mylocation,"%"+mymajor+"%").find(App.class);
Log.d("MainActivity2", "count " + datas.size());
if(datas.size()==0)
result="暂时没有数据。";
else{
result="省份 年份 专业 科类 批次 分数线";
for(App data:datas){
String Classes()+" "
+Location()+" "
+Year()+" "
+Major()+" "
+AdmissionBatch()+" "
+Score15();
result+="\n"+temp;
}
for(App data : datas) {
Log.d("MainActivity2", "num is " + Num());
Log.d("MainActivity2", "year is " + Year());
Log.d("MainActivity2", "location is " + Location());
Log.d("MainActivity2", "classes is " + Classes());
Log.d("MainActivity2", "major is " + Major());
Log.d("MainActivity2", "AD is " + AdmissionBatch());
Log.d("MainActivity2", "score is " + Score15());
}
}
2.直接⽤sql语句查询,返回Cursor,再依次读出
//plan B使⽤sql语句查询
Cursor c =DataSupport.findBySQL("select *" +
" from App where classes=? and location = ?" +
" and major like ?", myclasses,mylocation,"%"+mymajor+"%");
String loca="null",year="null",classes="null",major="null",ad="null",num="null"; double score=0.0;
Log.d("MainActivity2", "String: " +c.getCount()+mylocation+myclasses+mymajor); veToFirst()==false){
result="暂时查不到数据。";
}else{
result="省份 年份 专业 科类 批次 分数线";
veToFirst()){
do{
mysql下载ColumnIndex("location"));
ColumnIndex("year"));
ColumnIndex("major"));
//ColumnIndex("classes"));
//ColumnIndex("AdmissionBatch"));
ColumnIndex("score15"));
String temp= loca+" "
+year+" "
+major+" "
+classes+" "
+ad+" "
+score
;
result=result+"\n"+temp;
//Log.d("MainActivity2", "result: " +result );
}veToNext());
}
}
c.close();

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。