I want to select optional relationships in sql-server-2017-graph. Similar to optional
in sparql e.g.:
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?mbox
WHERE { ?x foaf:name ?name .
OPTIONAL { ?x foaf:mbox ?mbox }
}
from https://www.w3.org/2001/sw/DataAccess/rq23/#OptionalMatching.
And similar to LEFT JOIN
in normal sql; e.g.:
SELECT name, mbox
FROM Persons
LEFT JOIN PersonMailBoxLink ON Persons.$node_id = PersonMailBoxLink.$from_id
LEFT JOIN MailBoxes ON PersonMailBoxLink.$to_id = MailBoxes.$node_id
Is there an easier way via MATCH
?
The documentation of MATCH
describes no 'optional' construct and the remarks state:
OR
andNOT
operators are not supported in theMATCH
pattern.MATCH
can be combined with other expressions usingAND
in theWHERE
clause. However, combining it with other expressions usingOR
orNOT
is not supported.