1

I got the data model that has three nodes that are connected with three relations.

This is my data model

By looking at the model it makes no sense to me to store both 2 and 3 letter codes for each Country so I would like to delete all 2 letter ISO codes from countries.

I've tried to run the following code but I get no return.

  MATCH (n:Country)
  WHERE exists(n.iso_2_code)
  REMOVE n.iso_2_code
  RETURN n

What should I do? Is there an alternative way?

Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38
GiteNator
  • 25
  • 6
  • Your query looks correct from an openCypher perspective. If you take out the `REMOVE` line from the query do you get any results? I'm just wondering if the `MATCH` is actually finding anything. – Kelvin Lawrence Jan 26 '23 at 15:54
  • I've created a new Memgraph install. This time I've used Memgraph Cloud, and I got an error "Query failed: Function 'EXISTS' doesn't exist.". I kept on digging and I found in the documentation that Memgraph uses another way to to this (https://memgraph.com/docs/cypher-manual/differences): n.property IS NOT NULL. – GiteNator Jan 26 '23 at 20:42
  • 1
    Good to know - glad you found a solution – Kelvin Lawrence Jan 26 '23 at 20:59

1 Answers1

1

According to Memgraph documentation exists is not supported and one should use n.property IS NOT NULL.

The correct code is:

 MATCH (n:Country)
 WHERE n.iso_2_code IS NOT NULL
 REMOVE n.iso_2_code
 RETURN n
GiteNator
  • 25
  • 6