Does http://localhost:7474/browser/
not support multiple unrelated queries?
This code:
MATCH (a {cond:'1'}), (b {cond:'x'}) CREATE a-[:rel]->b MATCH (a {cond:'2'}), (b {cond:'y'}) CREATE a-[:rel]->b MATCH (a {cond:'3'}), (b {cond:'z'}) CREATE a-[:rel]->b
causes an error:
WITH is required between CREATE and MATCH
But since my queries aren't related, I don't think I shall need a WITH
.
How do I do the above without having to enter it one-line-at-a-time?
An OPTIONAL MATCH matches patterns against your graph database, just like a MATCH does. The difference is that if no matches are found, OPTIONAL MATCH will use a null for missing parts of the pattern. OPTIONAL MATCH could be considered the Cypher equivalent of the outer join in SQL.
To keep all the result rows, use UNION ALL . Using just UNION will combine and remove duplicates from the result set.
Return all elements When you want to return all nodes, relationships and paths found in a query, you can use the * symbol.
The MATCH clause allows you to specify the patterns Neo4j will search for in the database. This is the primary way of getting data into the current set of bindings. It is worth reading up more on the specification of the patterns themselves in Patterns.
As a work around you can do:
MATCH (a {cond:'1'}), (b {cond:'x'}) CREATE a-[:rel]->b WITH 1 as dummy MATCH (a {cond:'2'}), (b {cond:'y'}) CREATE a-[:rel]->b WITH 1 as dummy MATCH (a {cond:'3'}), (b {cond:'z'}) CREATE a-[:rel]->b
See also the import blog post: http://blog.neo4j.org/2014/01/importing-data-to-neo4j-spreadsheet-way.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With