在更新新值的列的所有行 [英] Update all rows in a column to new value
问题描述
道歉,我相信这已经被问很多次,但我已搜查了周围的一个很好的例子,并一直没能找到一个。
Apologies, I am sure this has been asked plenty of times but I have searched around for a good example and haven't been able to find one.
我想运行一个方法插入值转化为表中的所有行的特定列。为了让你的方法和我的工作查询一个想法,这是我工作的更新方法为我的学生表:
I'd like to run a method to insert a value into a particular column for all rows in a table. To give you an idea of the methods and queries I'm working with, this is my working update method for my Students table:
public void updateStudent(long id,String name, String age, String points,
String teachernote,byte[] blob) {
ContentValues cv = new ContentValues();
cv.put(Students.STUDENT_NAME, name);
cv.put(Students.STUDENT_AGE, age);
cv.put(Students.STUDENT_POINTS, points);
cv.put(Students.TEACHERNOTE, teachernote);
cv.put(Students.IMAGE,blob);
db = sqlHp.getWritableDatabase();
db.update(Students.TABLE, cv, Students.STUDENT_ID+"="+ id, null);
db.close();
}
我查询以更新所有行STUDENT_POINTS后我。任何帮助将是非常美联社preciated,谢谢你。
I'm after a query to update STUDENT_POINTS for all rows. Any help would be much appreciated, thank you.
推荐答案
如果您想更新您必须删除其中,
子句的所有行。在您的例子中,你应该删除 Students.STUDENT_ID +=+ ID
,从 db.update(Students.TABLE,CV,Students.STUDENT_ID += + ID,NULL);
If you want to update all rows you have to remove the where
clause. In your example you should remove Students.STUDENT_ID+"="+ id
, from db.update(Students.TABLE, cv, Students.STUDENT_ID+"="+ id, null);
这篇关于在更新新值的列的所有行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!