0Pricing
Neo4j Graph Database Fundamentals · Lezione

Restituire e modellare i risultati con RETURN

Imparate a padroneggiare la clausola Cypher RETURN per proiettare, assegnare alias e modellare l’output delle query sul grafo.

Restituire e modellare i risultati con RETURN è una lezione Neo4j Graph Database Fundamentals gratuita su CoddyKit. Questa è la lezione 4 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Neo4j Graph Database Fundamentals, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Neo4j Graph Database Fundamentals include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

What RETURN Does

Every read query that produces output ends with a RETURN clause. It defines exactly which values come back to you.

Think of RETURN as the projection step of your query.

MATCH (p:Person)
RETURN p;

Returning Specific Properties

Instead of whole nodes, you can return individual properties using dot notation. This keeps results lean.

MATCH (p:Person)
RETURN p.name, p.age;

Aliasing with AS

Use AS to rename a returned column. This makes output clearer and is essential when returning computed values.

MATCH (p:Person)
RETURN p.name AS personName, p.age AS years;

Returning Relationships

You can return the relationship variable too, not just nodes. This is useful when you need relationship properties.

MATCH (a:Person)-[r:FRIEND]->(b:Person)
RETURN a.name, type(r), b.name;

Computed Expressions

RETURN can contain expressions: arithmetic, string functions, and more.

MATCH (p:Person)
RETURN p.name, p.age * 12 AS ageInMonths;

DISTINCT Results

Add DISTINCT to remove duplicate rows from the output, just like in SQL.

MATCH (p:Person)-[:LIVES_IN]->(c:City)
RETURN DISTINCT c.name;

Returning Literals

You can return constant values and labels for readability or debugging.

RETURN 'Hello Cypher' AS greeting, 1 + 1 AS sum;

Returning Multiple Patterns

A single RETURN can combine values from many matched variables, building rich rows.

MATCH (u:User)-[:PLACED]->(o:Order)
RETURN u.name, o.id, o.total;

Working with Functions

Useful functions in RETURN include id(), labels(), type(), and toUpper().

MATCH (p:Person)
RETURN labels(p) AS nodeLabels, toUpper(p.name) AS upperName;

Returning a Whole Path

Capture a path in a variable and return it to inspect the full chain of nodes and relationships.

MATCH path = (a:Person {name: 'Alice'})-[:FRIEND*1..2]->(b)
RETURN path;

Keeping Output Clean

Best practice: return only what you need. Returning entire nodes when you only use one property wastes bandwidth and clutters results.

Quick Check

Test your RETURN knowledge.

Recap

You learned to shape query output with RETURN:

  • Return whole nodes or specific properties
  • Alias columns with AS
  • Use DISTINCT to remove duplicates
  • Include expressions and functions
  • Return paths and relationships when needed

Domande Frequenti

La lezione «Restituire e modellare i risultati con RETURN» è gratuita?

Sì — il testo completo di «Restituire e modellare i risultati con RETURN» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Neo4j Graph Database Fundamentals, passa a CoddyKit PRO. Il corso Neo4j Graph Database Fundamentals include 4 lezioni in totale.

Cosa imparerò in «Restituire e modellare i risultati con RETURN»?

Imparate a padroneggiare la clausola Cypher RETURN per proiettare, assegnare alias e modellare l’output delle query sul grafo. Eserciti Neo4j Graph Database Fundamentals con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare Neo4j Graph Database Fundamentals?

Non è richiesta alcuna esperienza precedente. Neo4j Graph Database Fundamentals su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 4 di 4.

Quanto tempo richiede la lezione «Restituire e modellare i risultati con RETURN»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione Neo4j Graph Database Fundamentals?

Sì. Ogni lezione Neo4j Graph Database Fundamentals include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. Nodi, relazioni e proprietà
  2. Creazione di dati con Cypher CREATE
  3. Corrispondenza di modelli con Cypher MATCH
  4. Restituire e modellare i risultati con RETURN
← Torna a Neo4j Graph Database Fundamentals