title: Get all friends in SQL Server graph database
body: <p>I'm trying to retrieve all friends of a particular person using SQL Server graph processing</p>
  
  <p><code>Person</code> table as <code>node</code></p>
  
  <pre>
  ╔════╦═══════╗
  ║ Id ║ Name  ║
  ╠════╬═══════╣
  ║  1 ║ David ║
  ║  2 ║ Suraj ║
  ║  3 ║ John  ║
  ║  4 ║ Ryan  ║
  ╚════╩═══════╝
  </pre>
  
  <p><code>likes</code> as an <code>edge</code>//for simplicity I am not using auto-generated ids here</p>
  
  <pre>
  ╔════╦═══════╦═══════╦═══════════════════╗
  ║ Id ║ From  ║  To   ║      Remarks      ║
  ╠════╬═══════╬═══════╬═══════════════════╣
  ║  1 ║ David ║ Suraj ║ David likes Suraj ║
  ║  2 ║ David ║ John  ║ David likes John  ║
  ║  3 ║ John  ║ Ryan  ║ John likes Ryan   ║
  ╚════╩═══════╩═══════╩═══════════════════╝
  </pre>
  
  <p>My graph query to find all friends of John would be like this</p>
  
  <pre><code>select p1.name, p2.name [friend]
  from person p1, likes l, person p2 
  where p1.name = 'John' and match(p1-(l)-&gt;p2)
  </code></pre>
  
  <p>and this will return the below result set</p>
  
  <pre>
  ╔══════╦════════╗
  ║ name ║ friend ║
  ╠══════╬════════╣
  ║ John ║ Ryan   ║
  ╚══════╩════════╝
  </pre>
  
  <p>The problem is we got all the people John likes, which excludes the people who likes John(in this case David). In real world, if a person is a friend of me, I am also a friend of him right?. I know I can use <code>union</code> here to find all people who likes John and add up to the above. But It will make the case worst for scenarios where finding friend of friends. Can we do it more intuitively tweaking with the <code>Match</code> or the arrows</p>
  
  <p>Expected Result</p>
  
  <pre>+------+--------+
  | Name | Friend |
  +------+--------+
  | John | Ryan   |
  | John | David  |
  +------+--------+</pre>
  
  <p><strong>update</strong>: expected result added</p>