Reputation: 11
I tried to create a query to update the number of rows of specific table:
UPDATE Albums (NumOfphotos)
VALUES (
SELECT COUNT(*)
FROM photos
WHERE AlbumName='nature'
)
WHERE AlbumName='nature';
This does not seem to be the right syntax,
what is the right way to do it (maybe by autokey)?
Upvotes: 1
Views: 1834
Reputation: 1297
This type of query is deliberately not supported by Cassandra nor CQL.
If you review the datastax CQL documentation for update you will see that the "where specification" only takes either a primary key or a IN(keys) clause:
primary key name = key_value
primary key name IN (key_value ,...)
So your best bet is to do a
SELECT * FROM photos WHERE AlbumName='nature';
followed by updates to set the correct values.
Upvotes: 2