A Cypher query can be part of a JOIN clause.

    1. Developers Note
    2. Cypher queries using the CREATE, SET, REMOVE clauses cannot be used in sql queries with JOINs, as they affect the Postgres transaction system. One possible solution is to protect the query with CTEs. See the subsection Using CTEs with CREATE, REMOVE, and SET for more details.

    Query:

    1. SELECT id,
    2. graph_query.name = t.name as names_match,
    3. graph_query.age = t.age as ages_match
    4. FROM schema_name.sql_person AS t
    5. JOIN cypher('graph_name', $$
    6. MATCH (n:Person)
    7. RETURN n.name, n.age, id(n)
    8. $$) as graph_query(name agtype, age agtype, id agtype)
    9. ON t.person_id = graph_query.id

    Results:

    id names_match ages_match
    1 True True
    2 False True
    3 True False
    3 row(s) returned