如何执行与mDb.update SQL语句? [英] How to execute the SQL statement with mDb.update?

查看:779
本文介绍了如何执行与mDb.update SQL语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该声明如下:

 更新mytable的SET displayed_value =(close_time_2 ||' - '|| open_time_2)
WHERE close_time_2!=

现在我把它与 mDb.execSQL 。如何执行与 mDb.update 一样吗? (需要看多少记录被更新)

更新:只是举一个例子。这里是我的数据库更新前:

 项目close_time_2 open_time_2 displayed_value
1 02:40 04:50
2 02:15 02:45
3 05:15

下面是我应该更新后获得

 项目close_time_2 open_time_2 displayed_value
1 02:40 04:50 02:40-04:50
2 02:15 02:45 02:15-02:45
3 05:15


解决方案

这真的不是很难找出如何使用更新 -method。见<一href=\"http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#update%28java.lang.String,%20android.content.ContentValues,%20java.lang.String,%20java.lang.String%5B%5D%29\"相对=nofollow>的文档这的Sample- $ C $ ç

The statement is the following:

UPDATE mytable SET displayed_value=(close_time_2 || '-' || open_time_2)
WHERE close_time_2 != ""

Now I call it with mDb.execSQL. How to execute the same with mDb.update? (need to see how many records were updated)

Update: just to give an example. Here is my database before update:

item  close_time_2  open_time_2  displayed_value
1     02:40         04:50
2     02:15         02:45
3                   05:15

here is what I should get after update

item  close_time_2  open_time_2  displayed_value
1     02:40         04:50        02:40-04:50
2     02:15         02:45        02:15-02:45
3                   05:15

解决方案

It's really not that hard to find out how to use the update-method. See the Docs and this Sample-code.

这篇关于如何执行与mDb.update SQL语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆