title: Cypher: Create relationships between nodes based on a common property key id
body: <p>I'm brand new to Cypher (and Stackoverflow) and am having trouble creating relationships between nodes based on share property keys.</p>
  
  <p>I would like to do something like this:</p>
  
  <pre><code>MATCH (a:Person)--&gt;()&lt;--(b:Country)
  WHERE HAS (a.id) AND HAS (b.id) AND a.id=b.id
  CREATE (a)-[:LIVES]-&gt;(b);
  </code></pre>
  
  <p>to create a relationship between Country node and Person nodes where they share the same id.</p>
  
  <p>The above creates no errors when run but doesn't create any relationships either and I know that the ids should match.</p>
  
  <p>Many thanks!!</p>
  
  <p>EDIT:</p>
  
  <p>I think I know what is going wrong - I'm asking to match nodes that have a relationship to eachother but no relationships are set up yet hence 0 results. I have now tried:</p>
  
  <pre><code>MATCH (a:Person),
  (b:Country)
  WHERE HAS (a.id) AND HAS (b.id) AND a.id=b.id
  CREATE (a)-[:LIVES]-&gt;(b);
  </code></pre>
  
  <p>and the query is running. It's a big data set so might take a while......</p>