0

I want to assign one column's values to another.

here is a query for it.

UPDATE contacts SET contactName=phone;

Here contactName and phone are two different columns.i am assigning phone column's values to contactName column.I can do this by using

db.execSQL(statement);

but if i want it to update it using

db.update(tableName, cValues, whereClause, whereArgs);

what should i put in Content values.If i put phone as a value then it will consider like

UPDATE contacts SET contactName="phone";

Is it possible using content values? Help me to solve this issue. Any help will be appreciated.Thanks in advance

1 Answer 1

2

You can't use ContentValues for that. You can only update/insert literal values with ContentValues, not column name references.

Just use execSQL() with the raw SQL you have. (Don't use rawQuery() - it alone won't execute your SQL.)

Sign up to request clarification or add additional context in comments.

3 Comments

sorry i have used execSQL but i want to do it using content values
That's not possible. What is the problem with the raw SQL approach?
actually i have implemented it using execSQL.but just i wanted to know about it.I googled it but couldn't find any solution.thats why i asked it here.bdw Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.