-1

I have a list of countries. I need to assign at least one language to a country if one is not already set. If one is set nothing shouldn't be done. How can I achieve this?

Taja Jan
  • 942
  • 1
  • 1
  • 11

1 Answers1

0

If you want to set a property only where one doesn't exist it should be checked against IS NULL.

MATCH (c:Country)
WHERE c.name = "Germany" AND c.language IS NULL
SET c.language = "German";

Since the WHERE clause contains the statement c.language IS NULL, the node will only be matched if it doesn’t have a language property.

Taja Jan
  • 942
  • 1
  • 1
  • 11