简体   繁体   中英

How to write Sparql query for the following result?

在此处输入图片说明 [![SPARQL Query Details][2]][2]

How should I write SPARQL query to get the details from node2 : URI for node2 is same in both the graphs and URI for node 1 is different. Thank you in advance.

as such, I need below details.

node2 def
hasID ghi
hasvertex jkl
hasLastname mno

To get all triples write SELECT ?node2 ?p ?o WHERE {?node2 ?p ?o} .

Now to restrict the results to graph 1 (defined by the URI of node1) you need to add <http://ex/abc> hasName ?node2 .

Together:

SELECT ?node2 ?p ?o WHERE{
  <http://ex/abc> hasName ?node2 .
  ?node2 ?p ?o
}

Just alter that SPARQL slightly to use real URIs for properties:

SELECT ?node2 ?p ?o
WHERE {
  <http://ex/node1> <http://ex/hasName> ?node2 .
  ?node2 ?p ?o .
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM