cancel
Showing results for 
Search instead for 
Did you mean: 

How to split query result

Hi,

When I run the querry like MATCH (a) RETURN a
the result (all node properties) is in one column/string.
I know that I can write RETURN a.prop1, a.prop2,.... to have properties in each column. But I look for a universal solution like if I do not know which properties one node has.
How is possible to split the query result (string) in multiple columns?

Regards and thank you

2 REPLIES 2

giuseppe_villan
Graph Fellow

@andrej.zivec

AFAIK, currently there is no way to do something like that without specify explicitly the columns,
see cypher - How to return all the properties in Neo4j to be in diffrent columns - Stack Overflow and Dynamic result columns using Neo4j Cypher - Stack Overflow.


Anyway, I don't know if is useful for your use case,
but maybe you could split the result in rows instead of columns, for example:

MATCH (a) 
WITH properties(a) as props
UNWIND keys(props) as propKey
RETURN propKey, props[propKey] as propValue

For example with this node, create (n:Test {a: 1, b: 2}),
I get:

propKey	| propValue
"a"	    | 1
"b"	    | 2

Sorry but this is not the case for me .... I need columns.
Anyway thank you for your answer it is also useful I learned something new

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.