Reputation: 223
I have created a keyspace with two column fields. One is Id and another one is name. I have inserted records in that keyspace. I want to update the name filed of a particular id.
I have used the following CQL query
UPDATE keyspaceName/columnFalmilyName SET name='name' WHERE id = 'id'
While Executing this query it throws the Exception of
InvalidRequestException(why:line 1:56 mismatched input 'id' expecting K_KEY)...
If the query framed is wrong means, how to update the record using CQL?
Upvotes: 1
Views: 11600
Reputation: 329
Have you tried: UPDATE keyspaceName/columnFalmilyName SET name='name' WHERE id = (without '')
Upvotes: 0
Reputation: 3890
Inserts and updates require specifying the row key, whereas you seem to be trying to use a column name. What key have you used when inserting new id,name pairs?
Refer to the CQL documentation on [http://cassandra.apache.org/doc/cql3/CQL.html][1]
<update-stmt> ::= UPDATE <tablename>
( USING <option> ( AND <option> )* )?
SET <assignment> ( ',' <assignment> )*
WHERE <where-clause>
The UPDATE statement writes one or more columns for a given row in a table. The
<where-clause> is used to select the row to update and must include all columns
composing the PRIMARY KEY. Other columns values are specified through <assignment>
after the SET keyword.
You need to take a look at your ColumnFamily definition and see what your primary key is.
Upvotes: 0