SQLite由浅入深

前端之家收集整理的这篇文章主要介绍了SQLite由浅入深前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1.怎样在数据库中一次插入多条数据?

DBHelper mDbHelper = new DBHelper(getApplication());
sqliteDatabase db = mDbHelper.getWritableDatabase();
String sql = "insert into logtable(name,urls,dece)values('梨花','荷花','木槿'),"('月季','牡丹','菊花')";
db.execsql(str);

2.怎样查找几条数据,但前几条跳过去?

sqliteDatabase db = mHelper.getWritableDatabase();
String sql = "select * from logtable limit 1,2";//这个事查找两条数据这两条数据之前的一条跳过去。
Cursor c = db.rawQuery(sql,null);

3.怎样模糊查询查询字段中包含“??”的数据?

//Cursor cccc=db.query("logtable",null,"name like '%"+88+"%'",null);
//Cursor cccc=db.query("logtable","name like ?",new String[]{"%"+8+"%"},null);
Cursor cccc=db.rawQuery("select * from logtable where name like '%"+"mlz"+"%'",null);


String[] selectioinArgs = {"%"+keyword+"%"};//注意:这里没有单引号 String sql = "select "+ TABLE_COLUMN_NAME +"," +TABLE_COLUMN_SYSTEM_NAME+ " from " + TABLE_NAME + " where " + TABLE_COLUMN_NAME + " like ? "; Cursor cursor = db.rawQuery(sql,selectioinArgs);

猜你在找的Sqlite相关文章