How to use SQL with Agens Graph in AGCloud's AGViewer if possible

122 Views Asked by At

I'm trying to use the SQL syntax in Agens Graph but I don't know to use it.

I tried the following query

SELECT * FROM MATCH result = ()-[]->() RETURN result;

Or

SELECT * FROM GRAPH MATCH result = ()-[]->() RETURN result;

but both gives me the following error

Syntax error at or near "MATCH"

5

There are 5 best solutions below

0
Ken W. On BEST ANSWER

You do not need to use SQL to wrap Cypher queries in AGViewer, instead just enter Cypher queries directly, for example:

SELECT * FROM cypher('graph_name', $$ MATCH result = ()-[]->() RETURN result $$) as (result agtype);

Can be simplified into the following in AGViewer:

MATCH result = ()-[]->() RETURN result;
2
Panagiotis Foliadis On

Try removing the SELECT * FROM and just use Cypher language.

0
Shanzay On

SELECT * FROM MATCH result = ()-[]->() RETURN result;

This seems incorrect. Select all from match? Usually after the FROM clause we enter the database name in SQL or the table name e.t.c.

Try dropping the SELECT clause and just use Cypher language.

0
Marcos Silva On

You don't need to use SELECT * FROM to run it. You only have to use the cypher to run the queries.

There is an example that you can use:

MATCH (n1)-[r]->(n2) RETURN n1, r, n2;

0
Shelender Kumar On

SELECT * clause should be avoided when using SQL syntax in Agens Graph. Cypher queries in Agens Graph be used, which is the query language specifically used for graph databases.

Here is how the query will look like:

MATCH result = ()-[]->()
RETURN result;