Abdul Manan
Abdul Manan

Reputation: 83

How can I create a table using a query on a graph database such that the node properties become the fields in the table?

I am using AGE and I want to create a table from the data stored in the nodes. The nodes in my graph database have properties that store data about the node. I need to write a query that returns the node data in a tabular format, with each property becoming a field in the table.

For example, if I have a node with properties name, age, and city, I want my query to return a table with three columns, name, age, and city, and one row for each node.

Upvotes: 1

Views: 117

Answers (1)

moeed865
moeed865

Reputation: 272

The following query will return properties in a tabular format:

SELECT * 
FROM cypher('graph',
$$
    MATCH (n)
    RETURN n.name, n.age, n.city
$$
) as (name agtype, age agtype, city agtype);

Upvotes: 1

Related Questions