Cookies help us deliver our services. By using our services, you agree to our use of cookies. More information

Difference between revisions of "Space Race/MATCH Tutorial"

From NoSQLZoo
Jump to: navigation, search
Line 9: Line 9:
 
==Institutions==
 
==Institutions==
 
<div class="q nonum" data-lang="neo4j">
 
<div class="q nonum" data-lang="neo4j">
   Use <code>MATCH</code> and <code>RETURN</code> to show nodes that are Institutions rather than Astronauts
+
   <p>Use <code>MATCH</code> and <code>RETURN</code> to show nodes that are Institutions rather than Astronauts</p>
 
   <p class='strong'>Show Institutions instead of Astronauts<p>
 
   <p class='strong'>Show Institutions instead of Astronauts<p>
 
   <pre class="def"><nowiki>MATCH(n:Astronaut) RETURN n;</nowiki>
 
   <pre class="def"><nowiki>MATCH(n:Astronaut) RETURN n;</nowiki>
Line 19: Line 19:
 
==Born in Russia==
 
==Born in Russia==
 
<div class="q nonum" data-lang="neo4j">
 
<div class="q nonum" data-lang="neo4j">
   Use <code>WHERE</code> to specify conditions
+
   <p>Use <code>WHERE</code> to specify conditions and the <code>.</code> operator to access individual</p>
   <p class='strong'>Show Astronauts born in Russia rather than the USA <p>
+
   <p class='strong'>Show the Surnames of Astronauts born in Russia rather than the USA <p>
   <pre class="def"><nowiki>MATCH(n:Astronaut)-[:BORN_IN]-(c:Country) WHERE c.name = 'United States of America' RETURN n;</nowiki>
+
   <pre class="def"><nowiki>MATCH(n:Astronaut)-[:BORN_IN]-(c:Country) WHERE c.name = 'United States of America' RETURN n.surname;</nowiki>
 
</pre>
 
</pre>
<pre class="ans"><nowiki>MATCH(n:Astronaut)-[:BORN_IN]-(c:Country) WHERE c.name = 'Russia' RETURN n;</nowiki>
+
<pre class="ans"><nowiki>MATCH(n:Astronaut)-[:BORN_IN]-(c:Country) WHERE c.name = 'Russia' RETURN n.surname;</nowiki>
 
</pre>
 
</pre>
 
</div>
 
</div>
  
 
{{Acknowledgements}}
 
{{Acknowledgements}}

Revision as of 10:08, 27 November 2019

Visualisation

Click here for 3d graph visualisation

Institutions

Use MATCH and RETURN to show nodes that are Institutions rather than Astronauts

Show Institutions instead of Astronauts

MATCH(n:Astronaut) RETURN n;
MATCH(n:Institution) RETURN n; 

Born in Russia

Use WHERE to specify conditions and the . operator to access individual

Show the Surnames of Astronauts born in Russia rather than the USA

MATCH(n:Astronaut)-[:BORN_IN]-(c:Country) WHERE c.name = 'United States of America' RETURN n.surname;
MATCH(n:Astronaut)-[:BORN_IN]-(c:Country) WHERE c.name = 'Russia' RETURN n.surname;

Acknowledgements

NoSQLZoo is made possible by the following open-source technologies:

jQuery JSHint CodeMirror MediaWiki MariaDB