jeudi 24 mai 2018

Cassandra CQL - update (insert) if not equal to

I have a scenario where I need to update (or insert) a record if a (non-key) field is not equal to some string OR the record does not exist. For example, given something like:

UPDATE mytable SET firstname='John', lastname='Doe' WHERE id='1' IF lastname != 'Doe';

If the lastname is not currently 'Doe', then update it, or if the record does not exist, update (insert) it. My assumption was that the IF condition would yield true if there was no record, but apparently not. Is there an alternative?

Aucun commentaire:

Enregistrer un commentaire