## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

# Querying nodes and relationships using Cypher

Cypher can be used to query nodes and relationships based on properties, relation types, labels, and so on. You can also write complex Cypher queries to query a subpart of the graph. In this recipe, we will learn some commonly used Cypher queries, which will be useful for querying the graph.

## Getting ready

To step through this recipe, you will need to create some nodes and relationships among them to get the most from this recipe.

## How to do it...

We have divided this recipe into the following problem sets:

• Counting all nodes that exist in the graph:
`START n = node(*) RETURN COUNT(n)`
• Counting all relationships that exist in the graph:
`MATCH (n)-[r]-(m) RETURN COUNT(r)`
• Finding all distinct labels that exist in ...

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required