0

I'm using Memgraph Lab for querying my graph database. Sometimes, I need to execute multiple Cypher queries in one go. How can I run multiple queries at once in the Memgraph Lab editor? When I run this:

MATCH (n:Person) WHERE n.name = 'Alice' RETURN n
MATCH (n:Person) WHERE n.age > 25 RETURN n

I get an error:

Query failed: MATCH can't be put after RETURN clause or after an update.

1 Answers1

0

So long as the return types are the same, in openCypher you should be able to use a UNION to combine these two

MATCH (n:Person) WHERE n.name = 'Alice' RETURN n
UNION
MATCH (n:Person) WHERE n.age > 25 RETURN n

you could also look at using an OR

MATCH (n:Person) WHERE n.name = 'Alice' OR n.age > 25 
RETURN n
Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38