我正在开发Android应用程序我想从sq-lite数据库表中删除最后两行。如果有人知道那么请帮助。
我实现了一个只删除最后一行的查询
PageView
答案 0 :(得分:1)
您可以使用此查询
"DELETE FROM my_chat WHERE project_id ='" + project_id + "' AND id in (select id from my_chat order by id desc limit 2)"
答案 1 :(得分:0)
您可以使用
toolbar.setNavigationOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
main = new Intent(SettingActivity.this, MainActivity.class);
main.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
finish();
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
startActivity(main);
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
}
});
答案 2 :(得分:0)
DELETE FROM my_chat WHERE project_id ='" + project_id + "' AND id IN (
SELECT id
FROM my_chat
ORDER BY id DESC
LIMIT 0, 2
)